1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

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

This commit is contained in:
Ian Dowse 2002-06-30 02:07:26 +00:00
parent dfc1b4ac01
commit 37777f4d1f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=99098
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);