The
cdbr library provides a space efficient (key,value) database based on perfect hashing.
A cdb database is opened for reading by calling
cdbr_open(). The only supported value for
flags is
CDBR_DEFAULT. The function returns a handle to pass to the other functions. The database is closed by invoking
cdbr_close(). All resources associated with the handle are freed and the memory returned by
cdbr_get() and
cdbr_find() is invalidated.
The number of records in the database can be obtained by calling
cdbr_entries(). Records can be obtained by record number using
cdbr_get() or by key using
cdbr_find(). Both functions return 0 on success and update
data and
datalen accordingly. The location
*data remains valid until
cdbr_close() is called. It is the responsibility of the caller of
cdbr_find() to ensure that the key matches the returned data. The function returns the only possible match, but the database doesn't store the keys to minimize overhead.