Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/xlint/lint2 lint: clean up initialization of lint2 s...



details:   https://anonhg.NetBSD.org/src/rev/7ee234adfa7e
branches:  trunk
changeset: 1026298:7ee234adfa7e
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Nov 16 22:03:12 2021 +0000

description:
lint: clean up initialization of lint2 symbol table

No functional change.

diffstat:

 usr.bin/xlint/lint2/externs2.h |   8 ++++----
 usr.bin/xlint/lint2/hash.c     |  20 +++++++++++---------
 usr.bin/xlint/lint2/main2.c    |   7 +++----
 usr.bin/xlint/lint2/read.c     |   6 +++---
 4 files changed, 21 insertions(+), 20 deletions(-)

diffs (130 lines):

diff -r 276e183f36b5 -r 7ee234adfa7e usr.bin/xlint/lint2/externs2.h
--- a/usr.bin/xlint/lint2/externs2.h    Tue Nov 16 21:38:29 2021 +0000
+++ b/usr.bin/xlint/lint2/externs2.h    Tue Nov 16 22:03:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: externs2.h,v 1.15 2021/09/05 18:17:15 rillig Exp $ */
+/* $NetBSD: externs2.h,v 1.16 2021/11/16 22:03:12 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -48,13 +48,13 @@
 /*
  * hash.c
  */
-extern void    _inithash(hte_t ***);
+extern hte_t** htab_new(void);
 extern hte_t   *_hsearch(hte_t **, const char *, bool);
+extern void    symtab_init(void);
 extern void    symtab_forall(void (*)(hte_t *));
+extern void    symtab_forall_sorted(void (*)(hte_t *));
 extern void    _destroyhash(hte_t **);
-extern void    symtab_forall_sorted(void (*)(hte_t *));
 
-#define        inithash()      _inithash(NULL);
 #define        hsearch(a, b)   _hsearch(NULL, (a), (b))
 
 /*
diff -r 276e183f36b5 -r 7ee234adfa7e usr.bin/xlint/lint2/hash.c
--- a/usr.bin/xlint/lint2/hash.c        Tue Nov 16 21:38:29 2021 +0000
+++ b/usr.bin/xlint/lint2/hash.c        Tue Nov 16 22:03:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hash.c,v 1.22 2021/08/28 21:52:14 rillig Exp $ */
+/*     $NetBSD: hash.c,v 1.23 2021/11/16 22:03:12 rillig Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: hash.c,v 1.22 2021/08/28 21:52:14 rillig Exp $");
+__RCSID("$NetBSD: hash.c,v 1.23 2021/11/16 22:03:12 rillig Exp $");
 #endif
 
 /*
@@ -57,14 +57,10 @@
 /*
  * Initialize hash table.
  */
-void
-_inithash(hte_t ***tablep)
+hte_t **
+htab_new(void)
 {
-
-       if (tablep == NULL)
-               tablep = &htab;
-
-       *tablep = xcalloc(HSHSIZ2, sizeof(**tablep));
+       return xcalloc(HSHSIZ2, sizeof(*htab_new()));
 }
 
 /*
@@ -151,6 +147,12 @@
        return strcmp(a->h_name, b->h_name);
 }
 
+void
+symtab_init(void)
+{
+       htab = htab_new();
+}
+
 /*
  * Call the action for each name in the hash table.
  */
diff -r 276e183f36b5 -r 7ee234adfa7e usr.bin/xlint/lint2/main2.c
--- a/usr.bin/xlint/lint2/main2.c       Tue Nov 16 21:38:29 2021 +0000
+++ b/usr.bin/xlint/lint2/main2.c       Tue Nov 16 22:03:12 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main2.c,v 1.22 2021/09/05 18:17:15 rillig Exp $        */
+/*     $NetBSD: main2.c,v 1.23 2021/11/16 22:03:12 rillig Exp $        */
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: main2.c,v 1.22 2021/09/05 18:17:15 rillig Exp $");
+__RCSID("$NetBSD: main2.c,v 1.23 2021/11/16 22:03:12 rillig Exp $");
 #endif
 
 #include <stdio.h>
@@ -155,8 +155,7 @@
 
        initmem();
 
-       /* initialize hash table */
-       inithash();
+       symtab_init();
 
        for (i = 0; i < argc; i++)
                readfile(argv[i]);
diff -r 276e183f36b5 -r 7ee234adfa7e usr.bin/xlint/lint2/read.c
--- a/usr.bin/xlint/lint2/read.c        Tue Nov 16 21:38:29 2021 +0000
+++ b/usr.bin/xlint/lint2/read.c        Tue Nov 16 22:03:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: read.c,v 1.67 2021/09/05 19:58:53 rillig Exp $ */
+/* $NetBSD: read.c,v 1.68 2021/11/16 22:03:12 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -38,7 +38,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: read.c,v 1.67 2021/09/05 19:58:53 rillig Exp $");
+__RCSID("$NetBSD: read.c,v 1.68 2021/11/16 22:03:12 rillig Exp $");
 #endif
 
 #include <ctype.h>
@@ -223,7 +223,7 @@
        if (thtab == NULL)
                thtab = xcalloc(THSHSIZ2, sizeof(*thtab));
 
-       _inithash(&renametab);
+       renametab = htab_new();
 
        srcfile = getfnidx(name);
 



Home | Main Index | Thread Index | Old Index