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
This commit is contained in:
parent
b878450725
commit
de19776b2f
|
@ -64,9 +64,7 @@ char *shname(char*);
|
|||
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);
|
||||
|
|
|
@ -30,30 +30,6 @@ symlook(char *sym, int space, void *install)
|
|||
return(s);
|
||||
}
|
||||
|
||||
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*))
|
||||
{
|
||||
|
@ -64,20 +40,3 @@ symtraverse(int space, void (*fn)(Symtab*))
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue