DragonFly On-Line Manual Pages

Search: Section:  


HASHINIT(9)           DragonFly Kernel Developer's Manual          HASHINIT(9)

NAME

hashinit, hashinit_ext, hashdestroy, phashinit, phashinit_ext -- generic hash table 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 hashdestroy(void *hashtbl, 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. The hashdestroy() function frees the space occupied by the hash table pointed to by argument hashtbl. Argument type determines the malloc arena to use when freeing space. The argument hashmask should be the bit mask returned by the call to hashinit() that allocated the hash table. The argument flags must be used with one of the following values.

SEE ALSO

tcp(4), udp(4), kmalloc(9), nlookup(9)

AUTHORS

This manual page was written by Hiten Pandya <hmp@backplane.com>.

BUGS

There is no phashdestroy() function, and using hashdestroy() to free a hash table allocated by phashinit() usually has grave consequences. DragonFly 3.5 June 6, 2012 DragonFly 3.5

Search: Section: