hcreate()

Create a hash search table

Synopsis:

#include <search.h>

int hcreate( size_t nel );

Arguments:

nel
An estimate of the maximum number of entries that the table will contain. The algorithm might adjust this number upward in order to obtain certain mathematically favorable circumstances.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The hcreate() function allocates space for the hash search table. You must call this function before using hsearch().

The hsearch() and hcreate() functions use malloc() to allocate space.

Only one hash search table may be active at any given time. You can destroy the table by calling hdestroy().

Returns:

0 if there isn't enough space available to allocate the table.

Examples:

See hsearch().

Classification:

POSIX 1003.1 XSI

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

bsearch(), hdestroy(), hsearch(), malloc()

The Art of Computer Programming, Volume 3, Sorting and Searching by Donald E. Knuth, published by Addison-Wesley Publishing Company, 1973.