diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-02-26 03:16:48 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-02-26 03:16:48 +0000 |
commit | 5f6a867ae004d358af657467ae21284940ce6e8c (patch) | |
tree | bd77ddb50decbbbdc7c88a347678466d9b8ba2b1 /sys/kern/kern_subr.c | |
parent | 39033054ba4c7e768ccdbaea8dfb3e606f691dcc (diff) |
Add newhashinit(), which is identical to hashinit() except it takes a flags
arg for passing to malloc() (hashinit always uses M_WAITOK which is not
always what you want). Everything that uses hashinit should really
get converted to newhashinit and then newhashinit can be renamed.
Diffstat (limited to 'sys/kern/kern_subr.c')
-rw-r--r-- | sys/kern/kern_subr.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/kern_subr.c b/sys/kern/kern_subr.c index 0f8eb3f76c0..8b5e31397a7 100644 --- a/sys/kern/kern_subr.c +++ b/sys/kern/kern_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_subr.c,v 1.6 1998/07/28 00:13:08 millert Exp $ */ +/* $OpenBSD: kern_subr.c,v 1.7 1999/02/26 03:16:47 millert Exp $ */ /* $NetBSD: kern_subr.c,v 1.15 1996/04/09 17:21:56 ragge Exp $ */ /* @@ -156,6 +156,14 @@ hashinit(elements, type, hashmask) int elements, type; u_long *hashmask; { + return newhashinit(elements, type, M_WAITOK, hashmask); +} + +void * +newhashinit(elements, type, flags, hashmask) + int elements, type, flags; + u_long *hashmask; +{ long hashsize; LIST_HEAD(generic, generic) *hashtbl; int i; @@ -165,7 +173,7 @@ hashinit(elements, type, hashmask) for (hashsize = 1; hashsize <= elements; hashsize <<= 1) continue; hashsize >>= 1; - hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl), type, M_WAITOK); + hashtbl = malloc((u_long)hashsize * sizeof(*hashtbl), type, flags); for (i = 0; i < hashsize; i++) LIST_INIT(&hashtbl[i]); *hashmask = hashsize - 1; |