DragonFly On-Line Manual Pages
HASHINIT(9) DragonFly Kernel Developer's Manual HASHINIT(9)
hashinit, hashinit_ext, hashdestroy, phashinit, phashinit_ext -- generic
hash table functions for the kernel
hashinit(int count, struct malloc_type *type, u_long *hashmask);
hashinit_ext(int count, size_t size, struct malloc_type *type,
hashdestroy(void *hashtbl, struct malloc_type *type, u_long hashmask);
phashinit(int count, struct malloc_type *type, u_long *nentries);
phashinit_ext(int count, size_t size, struct malloc_type *type,
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.
tcp(4), udp(4), kmalloc(9), nlookup(9)
This manual page was written by Hiten Pandya <email@example.com>.
There is no phashdestroy() function, and using hashdestroy() to free a
hash table allocated by phashinit() usually has grave consequences.
DragonFly 4.3 June 6, 2012 DragonFly 4.3