hcreate() — Create hash search tables

Standards

Standards / Extensions C or C++ Dependencies

XPG4
XPG4.2
Single UNIX Specification, Version 3

both  

Format

#define _XOPEN_SOURCE
#include <search.h>

int hcreate(size_t nel);

General description

The hcreate() function allocates sufficient space for a hash table containing nel elements, and must be called before hsearch() is used.

The nel argument is an estimate of the maximum number of entries that the table will contain. This number may be adjusted upward by hcreate() for the actual table allocation in order to obtain certain mathematically favorable circumstances.

Threading Behavior: see hsearch() — Search hash tables.

Returned value

If successful, hcreate() returns nonzero.

If hcreate() cannot allocate sufficient space for the table, it returns 0 and sets errno to one of the following values:
Error Code
Description
ENOMEM
Insufficient storage space is available.

Related information