The hcreate function creates an in-memory database. The <spanclass="bold"><strong>nelem</strong></span> parameter is an estimation of the maximum
number of key/data pairs that will be stored in the database.
</p>
<p>
The <spanclass="bold"><strong>hdestroy</strong></span> function discards the
database.
</p>
<p>
Database elements are structures of type <spanclass="bold"><strong>ENTRY</strong></span>, which contain at least two fields:
<spanclass="bold"><strong>key</strong></span> and <spanclass="bold"><strong>data</strong></span>. The field <spanclass="bold"><strong>key</strong></span> is declared to be of type <spanclass="bold"><strong>char *</strong></span>, and is the key used for storage and
retrieval. The field <spanclass="bold"><strong>data</strong></span> is
declared to be of type <spanclass="bold"><strong>void *</strong></span>, and is
its associated data.
</p>
<p>
The hsearch function retrieves key/data pairs from, and stores
key/data pairs into the database.
</p>
<p>
The <spanclass="bold"><strong>action</strong></span> parameter must be set to
one of two values:
</p>
<divclass="itemizedlist">
<ultype="disc">
<li>
<p>
<spanclass="bold"><strong>ENTER</strong></span>
</p>
<p>
If the key does not already appear in the database, insert the
key/data pair into the database. If the key already appears in the
database, return a reference to an <spanclass="bold"><strong>ENTRY</strong></span> structure which refers to the existing
key and its associated data element.
</p>
</li>
<li>
<p>
<spanclass="bold"><strong>FIND</strong></span>
</p>
<p>
Retrieve the specified key/data pair from the database.
The <spanclass="bold"><strong>hcreate</strong></span> function returns 0 on
failure, setting <spanclass="bold"><strong>errno</strong></span>, and non-zero
on success.
</p>
<p>
The <spanclass="bold"><strong>hsearch</strong></span> function returns a
pointer to an ENTRY structure on success, and NULL, setting <spanclass="bold"><strong>errno</strong></span>, if the <spanclass="bold"><strong>action</strong></span> specified was FIND and the item did not
The <spanclass="bold"><strong>hsearch</strong></span> function will fail,
setting <spanclass="bold"><strong>errno</strong></span> to 0, if the <spanclass="bold"><strong>action</strong></span> specified was FIND and the item did not
appear in the database.
</p>
<p>
In addition, the hcreate, hsearch and hdestroy functions may fail and
return an error for errors specified for other Berkeley DB and C