ref: de19776b2f793de7fdf1111d84d96eb29f9a22fd
parent: b878450725de85dc874f42bc9de4ce1d5087f900
author: cinap_lenrek <[email protected]>
date: Wed Jun 1 20:12:36 EDT 2016
mk: remove buggy and useless symtab functions (thanks qrstuv) neither symdel nor symstat were used anywhere. syminit was used but had no effect. both syminit and symdel dereference pointers after freeing them. symstat can be tricked into writing beyond the bounds of its array
--- a/sys/src/cmd/mk/fns.h
+++ b/sys/src/cmd/mk/fns.h
@@ -64,9 +64,7 @@
void shprint(char*, Envy*, Bufblock*);
Word *stow(char*);
void subst(char*, char*, char*, int);
-void symdel(char*, int);
Symtab *symlook(char*, int, void*);
-void symstat(void);
void symtraverse(int, void(*)(Symtab*));
void timeinit(char*);
long timeof(char*, int);
--- a/sys/src/cmd/mk/symtab.c
+++ b/sys/src/cmd/mk/symtab.c
@@ -31,30 +31,6 @@
}
void
-symdel(char *sym, int space)
-{
- long h;
- char *p;
- Symtab *s, *ls;
-
- /* multiple memory leaks */
-
- for(p = sym, h = space; *p; h += *p++)
- h *= HASHMUL;
- if(h < 0)
- h = ~h;
- h %= NHASH;
- for(s = hash[h], ls = 0; s; ls = s, s = s->next)
- if((s->space == space) && (strcmp(s->name, sym) == 0)){
- if(ls)
- ls->next = s->next;
- else
- hash[h] = s->next;
- free((char *)s);
- }
-}
-
-void
symtraverse(int space, void (*fn)(Symtab*))
{
Symtab **s, *ss;
@@ -63,21 +39,4 @@
for(ss = *s; ss; ss = ss->next)
if(ss->space == space)
(*fn)(ss);
-}
-
-void
-symstat(void)
-{
- Symtab **s, *ss;
- int n;
- int l[1000];
-
- memset((char *)l, 0, sizeof(l));
- for(s = hash; s < &hash[NHASH]; s++){
- for(ss = *s, n = 0; ss; ss = ss->next)
- n++;
- l[n]++;
- }
- for(n = 0; n < 1000; n++)
- if(l[n]) Bprint(&bout, "%d of length %d\n", l[n], n);
}