From 5f6a867ae004d358af657467ae21284940ce6e8c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Fri, 26 Feb 1999 03:16:48 +0000 Subject: 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. --- sys/kern/kern_subr.c | 12 ++++++++++-- sys/sys/systm.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'sys') 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 $ */ /* @@ -155,6 +155,14 @@ void * 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; @@ -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; diff --git a/sys/sys/systm.h b/sys/sys/systm.h index d9308b689ff..9ecad1403a3 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.25 1999/01/10 13:34:16 niklas Exp $ */ +/* $OpenBSD: systm.h,v 1.26 1999/02/26 03:16:47 millert Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -140,6 +140,7 @@ void vfs_op_init __P((void)); int seltrue __P((dev_t dev, int which, struct proc *)); void *hashinit __P((int, int, u_long *)); +void *newhashinit __P((int, int, int, u_long *)); int sys_nosys __P((struct proc *, void *, register_t *)); void panic __P((const char *, ...)) -- cgit v1.2.3