summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-02-26 03:16:48 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-02-26 03:16:48 +0000
commit5f6a867ae004d358af657467ae21284940ce6e8c (patch)
treebd77ddb50decbbbdc7c88a347678466d9b8ba2b1 /sys
parent39033054ba4c7e768ccdbaea8dfb3e606f691dcc (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')
-rw-r--r--sys/kern/kern_subr.c12
-rw-r--r--sys/sys/systm.h3
2 files changed, 12 insertions, 3 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;
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 *, ...))