Add a hashdestroy() function to undo the actions of hashinit().

This commit is contained in:
iedowse 2002-06-30 02:07:26 +00:00
parent ab92b92516
commit b5040e7472
2 changed files with 16 additions and 0 deletions

View File

@ -495,6 +495,21 @@ hashinit(elements, type, hashmask)
return (hashtbl);
}
void
hashdestroy(vhashtbl, type, hashmask)
void *vhashtbl;
struct malloc_type *type;
u_long hashmask;
{
LIST_HEAD(generic, generic) *hashtbl, *hp;
hashtbl = vhashtbl;
for (hp = hashtbl; hp <= &hashtbl[hashmask]; hp++)
if (!LIST_EMPTY(hp))
panic("hashdestroy: hash not empty");
free(hashtbl, type);
}
static int primes[] = { 1, 13, 31, 61, 127, 251, 509, 761, 1021, 1531, 2039,
2557, 3067, 3583, 4093, 4603, 5119, 5623, 6143, 6653,
7159, 7673, 8191, 12281, 16381, 24571, 32749 };

View File

@ -123,6 +123,7 @@ int nullop(void);
int eopnotsupp(void);
int seltrue(dev_t dev, int which, struct thread *td);
int ureadc(int, struct uio *);
void hashdestroy(void *, struct malloc_type *, u_long);
void *hashinit(int count, struct malloc_type *type, u_long *hashmask);
void *phashinit(int count, struct malloc_type *type, u_long *nentries);