cp_hashtable_get(3) - Linux man page

Name

cp_hashtable_get, cp_hashtable_get_by_option - lookup a hashtable entry by key

Synopsis

#include <cprops/hashtable.h>

void *cp_hashtable_get(cp_hashtable *table, void *key);
void *cp_hashtable_get_by_option(cp_hashtable *
table, void *key,

int mode);

Description

cp_hashtable_get looks up the value stored under key. cp_hashtable_get_by_option allows specifying the retrieval mode as well. If COLLECTION_MODE_MULTIPLE_VALUES is set the hashtable is searched for multiple matches for key and the result, even if it is a single item, is returned in a newly created cp_list. The result list is created with the same mode, value copy function and value destructor as the hashtable. Hence the result list contains copies of values if COLLECTION_MODE_COPY was set on the table, and calling the list destructor triggers calls to the value finalization function if COLLECTION_MODE_DEEP is set. Also note that like cp_list_iterator and cp_hashlist_iterator the table and the result list share the same synchronization mechanism. These features add up to a consistent api behavior but also introduce certain subtleties. Potential complications are avoided by refraining from using the COLLECTION_MODE_DEEP bit with hashtables.

Return Value

get functions return the value the key maps to, or if COLLECTION_MODE_MULTIPLE_VALUES is set, a pointer to a newly created cp_list containing all matches; or NULL on error or if there is no mapping for the specified key. NULL may also be returned if a locking error occurs.

Errors

EINVAL

- the table or key parameter are NULL.

ENOMEM

- COLLECTION_MODE_MULTIPLE_VALUES is set and the result list creation failed.

EDEADLK
- a locking error occured. This should not normally come up unless accessing the collection lock directly rather than using api calls.

See Also

cp_hashtable(3), cp_hashlist_get(3), cp_list(3)

Referenced By

cp_hashtable_contains(3), cp_hashtable_put(3), cp_hashtable_set_mode(3)