Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
hcreate(3)
Edit
PageHistory
Diff
Info
LikePages
HSEARCH !!!HSEARCH NAME SYNOPSIS DESCRIPTION RETURN VALUE CONFORMS TO BUGS EXAMPLE SEE ALSO ---- !!NAME hcreate, hdestroy, hsearch - hash table management !!SYNOPSIS __#include __ ''item''__, ACTION__ ''action''__); int hcreate(unsigned__ ''nel''__); void hdestroy(void); __ !!DESCRIPTION These three functions allow the user to create a hash table which associates a key with any data. First the table must be created with the function __hcreate()__. ''nel'' is an estimate of the number of entries in the table. __hcreate()__ may adjust this value upward to improve the performance of the resulting hash table. The GNU implementation of __hsearch()__ will also enlarge the table if it gets nearly full. malloc(3) is used to allocate space for the table. The corresponding function __hdestroy()__ frees the memory occupied by the hash table so that a new table can be constructed. ''item'' is of type __ENTRY__, which is a typedef defined in '''' and includes these elements: typedef struct entry { char *''key''; char *''data''; } ENTRY; ''key'' points to the zero-terminated ASCII string which is the search key. ''data'' points to the data associated with that key. (A pointer to a type other than character should be cast to pointer-to-character.) __hsearch()__ searches the hash table for an item with the same key as ''item'', and if successful returns a pointer to it. ''action'' determines what __hsearch()__ does after an unsuccessful search. A value of __ENTER__ instructs it to insert the new item, while a value of __FIND__ means to return __NULL__. !!RETURN VALUE __hcreate()__ returns __NULL__ if the hash table cannot be successfully installed. __hsearch()__ returns __NULL__ if ''action'' is __ENTER__ and there is insufficient memory to expand the hash table, or ''action'' is __FIND__ and ''item'' cannot be found in the hash table. !!CONFORMS TO SVID, except that in SysV, the hash table cannot grow. !!BUGS The implementation can manage only one hash table at a time. Individual hash table entries can be added, but not deleted. !!EXAMPLE The following program inserts 24 items in to a hash table, then prints some of them. #include !!SEE ALSO bsearch(3), lsearch(3), tsearch(3), malloc(3) ----
One page links to
hcreate(3)
:
Man3h
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.