HSEARCH(3)

NAME
hcreate, hdestroy, hsearch - hash table management

SYNOPSIS
#include <search.h>

ENTRY *hsearch(ENTRY item, ACTION action);

DESCRIPTION
This three functions allow the user to create a hash table of type ENTRY (defined in <search.h>) which associates a key with any data. The implementation uses malloc(3).

First the table must be created with the function hcreate(). nel is an estimation of the table size which will suffice the needs. For better algorithms this value can be corrected upwards.

The corresponding function hdestroy() frees the memory occupied by the hash table for that a new table can be constructed.

hsearch() is the function for searching and inserting. Which action is done is controlled by the parameter action. It is of the type ACTION (also defined in <search.h>) and can have the values ENTER or FIND. ENTER means to insert the given item and FIND means to only search. Unsuccesful actions result in a return value NULL.

RETURN VALUE
hcreate() return zero if the hash table cannot be succesfully installed.

hsearch() return NULL if either action is ENTER and the hash table is full or action is FIND and the item cannot be find in the hash table.

BUGS
The implementation can manage only one hash table at a time.

SEE ALSO
bsearch(3),lsearch(3),malloc(3)