Module Name: src Committed By: rillig Date: Tue Nov 16 22:03:12 UTC 2021
Modified Files: src/usr.bin/xlint/lint2: externs2.h hash.c main2.c read.c Log Message: lint: clean up initialization of lint2 symbol table No functional change. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/usr.bin/xlint/lint2/externs2.h cvs rdiff -u -r1.22 -r1.23 src/usr.bin/xlint/lint2/hash.c \ src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.67 -r1.68 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/xlint/lint2/externs2.h diff -u src/usr.bin/xlint/lint2/externs2.h:1.15 src/usr.bin/xlint/lint2/externs2.h:1.16 --- src/usr.bin/xlint/lint2/externs2.h:1.15 Sun Sep 5 18:17:15 2021 +++ src/usr.bin/xlint/lint2/externs2.h Tue Nov 16 22:03:12 2021 @@ -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 @@ extern bool Fflag; /* * 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 _destroyhash(hte_t **); extern void symtab_forall_sorted(void (*)(hte_t *)); +extern void _destroyhash(hte_t **); -#define inithash() _inithash(NULL); #define hsearch(a, b) _hsearch(NULL, (a), (b)) /* Index: src/usr.bin/xlint/lint2/hash.c diff -u src/usr.bin/xlint/lint2/hash.c:1.22 src/usr.bin/xlint/lint2/hash.c:1.23 --- src/usr.bin/xlint/lint2/hash.c:1.22 Sat Aug 28 21:52:14 2021 +++ src/usr.bin/xlint/lint2/hash.c Tue Nov 16 22:03:12 2021 @@ -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 @@ static hte_t **htab; /* * 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 @@ hte_by_name(const void *va, const void * 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. */ Index: src/usr.bin/xlint/lint2/main2.c diff -u src/usr.bin/xlint/lint2/main2.c:1.22 src/usr.bin/xlint/lint2/main2.c:1.23 --- src/usr.bin/xlint/lint2/main2.c:1.22 Sun Sep 5 18:17:15 2021 +++ src/usr.bin/xlint/lint2/main2.c Tue Nov 16 22:03:12 2021 @@ -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 @@ main(int argc, char *argv[]) initmem(); - /* initialize hash table */ - inithash(); + symtab_init(); for (i = 0; i < argc; i++) readfile(argv[i]); Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.67 src/usr.bin/xlint/lint2/read.c:1.68 --- src/usr.bin/xlint/lint2/read.c:1.67 Sun Sep 5 19:58:53 2021 +++ src/usr.bin/xlint/lint2/read.c Tue Nov 16 22:03:12 2021 @@ -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 @@ readfile(const char *name) if (thtab == NULL) thtab = xcalloc(THSHSIZ2, sizeof(*thtab)); - _inithash(&renametab); + renametab = htab_new(); srcfile = getfnidx(name);