HASH(9) BSD Kernel Developer's Manual HASH(9)NAME
hash, hashinit, hashinit_ext, phashinit, phashinit_ext — generic hash ta‐
ble functions for the kernel
SYNOPSIS
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
void *
hashinit(int count, struct malloc_type *type, u_long *hashmask);
void *
hashinit_ext(int count, size_t size, struct malloc_type *type,
u_long *hashmask);
void *
phashinit(int count, struct malloc_type *type, u_long *nentries);
void *
phashinit_ext(int count, size_t size, struct malloc_type *type,
u_long *nentries);
DESCRIPTION
The kernel hash functions are used for creating a generic hash table.
The hashinit() function returns a pointer to a hash table which is sized
a “power of two” greater or equal to the element count requested. The
masking value is stored in hashmask.
The phashinit() function returns a pointer to a prime number sized hash
table. The element count requested is used to dictate an upper-bound for
the size of the hash table. The final size of the hash table is stored
by the function in nentries.
The type argument to both of the above functions is used for keeping
track of memory allocated for the hash table. See the kmalloc(9) manual
page for more information on memory statistics.
The hashinit_ext() and phashinit_ext() functions are extended versions of
hashinit() and phashinit() which take the size of the structure as an
additional argument and will zero the array instead of assuming that it
is an array of LIST_HEADs.
SEE ALSOtcp(4), udp(4), kmalloc(9), nlookup(9)AUTHORS
This manual page was written by Hiten Pandya ⟨hmp@backplane.com⟩.
BSD December 20, 2009 BSD