Functions | |
| int | u_hmap_easy_new (u_hmap_opts_t *opts, u_hmap_t **phmap) |
| Create a new hmap. | |
| void | u_hmap_easy_clear (u_hmap_t *hmap) |
| Clear hmap. | |
| void | u_hmap_easy_free (u_hmap_t *hmap) |
| Deallocate hmap. | |
| int | u_hmap_easy_put (u_hmap_t *hmap, const char *key, const void *val) |
| Insert an object into the hmap. | |
| void * | u_hmap_easy_get (u_hmap_t *hmap, const char *key) |
| Retrieve a value from the hmap. | |
| int | u_hmap_easy_del (u_hmap_t *hmap, const char *key) |
| Delete an object from the hmap. | |
| void u_hmap_easy_clear | ( | u_hmap_t * | hmap | ) |
See u_hmap_clear().
| hmap | hmap object |
Definition at line 302 of file srcs/toolbox/hmap.c.
References u_hmap_clear().
| int u_hmap_easy_del | ( | u_hmap_t * | hmap, | |
| const char * | key | |||
| ) |
Delete object with given key from hmap.
| hmap | hmap object | |
| key | key of object to be deleted |
| U_HMAP_ERR_NONE | on success | |
| U_HMAP_ERR_FAIL | on failure |
Definition at line 398 of file srcs/toolbox/hmap.c.
References u_hmap_del().
| void u_hmap_easy_free | ( | u_hmap_t * | hmap | ) |
Deallocate hmap along with all hmapd objects. Objects are freed by using the function pointer specified with u_hmap_opts_set_val_freefunc() if it is not NULL.
| hmap | hmap object |
Definition at line 318 of file srcs/toolbox/hmap.c.
References u_hmap_free().
Referenced by u_json_free(), u_json_index(), and u_json_unindex().
| void* u_hmap_easy_get | ( | u_hmap_t * | hmap, | |
| const char * | key | |||
| ) |
Retrieve the value with given key from hmap.
| hmap | hmap object | |
| key | key to be retrieved |
NULL on failure or no match Definition at line 378 of file srcs/toolbox/hmap.c.
References u_hmap_get().
Referenced by u_json_cache_get().
| int u_hmap_easy_new | ( | u_hmap_opts_t * | opts, | |
| u_hmap_t ** | phmap | |||
| ) |
Create a new hmap object and save its pointer to *hmap. The call may fail on memory allocation problems or if the options are manipulated incorrectly.
| opts | options to be passed to the hmap | |
| phmap | on success contains the hmap options object |
| U_HMAP_ERR_NONE | on success | |
| U_HMAP_ERR_FAIL | on failure |
Definition at line 274 of file srcs/toolbox/hmap.c.
References u_hmap_new(), u_hmap_opts_copy(), and u_hmap_opts_init().
Referenced by u_json_index().
| int u_hmap_easy_put | ( | u_hmap_t * | hmap, | |
| const char * | key, | |||
| const void * | val | |||
| ) |
Insert a key, val pair into hmap.
The size of val copied into the hmap is based on its type set using u_hmap_opts_set_val_type():
Values are not overwritten if a value already exists in the hmap for a given key, unless U_HMAP_OPTS_NO_OVERWRITE is explicitly unset using u_hmap_opts_unset_option().
| hmap | hmap object | |
| key | key to be inserted | |
| val | value to be inserted |
| U_HMAP_ERR_NONE | on success | |
| U_HMAP_ERR_EXISTS | if key already exists | |
| U_HMAP_ERR_FAIL | on other failures |
Definition at line 353 of file srcs/toolbox/hmap.c.
References u_hmap_o_new(), and u_hmap_put().