Functions | |
int | u_hmap_new (u_hmap_opts_t *opts, u_hmap_t **hmap) |
Create a new hmap. | |
int | u_hmap_del (u_hmap_t *hmap, const char *key) |
Delete an object from the hmap. | |
int | u_hmap_put (u_hmap_t *hmap, const char *key, void *val) |
Insert an object into the hmap. | |
int | u_hmap_get (u_hmap_t *hmap, const char *key, void **val) |
Retrieve an object from the hmap. | |
int | u_hmap_foreach (u_hmap_t *hmap, int f(void *val)) |
Perform an operation on all objects. | |
int | u_hmap_free (u_hmap_t *hmap) |
Deallocate the hmap. | |
int | u_hmap_opts_new (u_hmap_opts_t **opts) |
Create new hmap options. |
|
Delete object with given key from hmap.
|
|
Execute function f on all objects within hmap. These functions should return 0 on success, and take an object as a parameter.
|
|
Deallocate hmap along with options and all hmapd objects. Objects are freed via free() by default or using the custom deallocation function passed in the hmap options.
Definition at line 600 of file hmap.c. References u_free(). |
|
Retrieve object with given key from hmap. On success the requested object is returned in val. The object is not removed from the hmap, so ownership of the object is not returned to the user.
|
|
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.
Definition at line 181 of file hmap.c. References u_free(), u_hmap_opts_new(), and u_zalloc(). |
|
Create a new hmap options object and save its pointer to *opts. The fields within the object can be manipulated publicly according to the description in the header file.
Definition at line 644 of file hmap.c. References u_hmap_opts_s::f_comp, u_hmap_opts_s::f_free, u_hmap_opts_s::f_hash, u_hmap_opts_s::f_str, u_hmap_opts_s::max_elems, u_hmap_opts_s::max_size, u_hmap_opts_s::policy, and u_zalloc(). Referenced by u_hmap_new(). |
|
Insert a {key:val} pair into hmap. The object must be allocated externally, but its ownership passes to hmap. Hence, the appropriate object deallocation function should be set in the relative options field.
|