HASHINIT(9) | Kernel Developer's Manual | HASHINIT(9) |
void *
hashinit(u_int chains, enum hashtype htype, bool waitok, u_long *hashmask);
void
hashdone(void *hashtbl, enum hashtype htype, u_long hashmask);
If waitok is true, hashinit can wait until enough memory is available. Otherwise, it immediately fails if there is not enough memory is available.
A value will be stored into *hashmask suitable for masking any computed hash, to obtain the index of a chain head in the allocated table.
The hashdone() function deallocates the storage allocated by hashinit() and pointed to by hashtbl, given the same htype and hashmask that were passed to and returned from hashinit(). If the table contains any nonempty chain when hashdone() is called, the result is undefined.
NetBSD 1.0 was the first NetBSD release to have a hashinit() function. It resembled that from 4.4BSD but made each slot a LIST_HEAD from queue(3). For NetBSD 1.3.3 it had been changed to size the table to the least power of two not less than or equal to chains. By NetBSD 1.4 it had the mflags argument and the current sizing rule.
NetBSD 1.5 had the hashdone() function. By NetBSD 1.6 hashinit() supported LIST or TAILQ chains selected with htype.
FreeBSD has a hashinit() with behavior equivalent (as of FreeBSD 6.1) to that in NetBSD 1.0, and a hashdestroy() that behaves as hashdone() but checks that all chains are empty first. OpenBSD has a hashinit() comparable (as of OpenBSD 3.9) to that of NetBSD 1.4. This manual page was added for NetBSD 4.0.
July 1, 2008 | NetBSD 6.1 |