Main Page | Modules | Data Structures | File List | Data Fields

Map


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.

Function Documentation

int u_hmap_del u_hmap_t *  hmap,
const char *  key
 

Delete object with given key from hmap.

Parameters:
hmap hmap object
key key of object to be deleted
Returns:
0 on success, non-zero on failure

Definition at line 274 of file hmap.c.

int u_hmap_foreach u_hmap_t *  hmap,
int   f(void *val)
 

Execute function f on all objects within hmap. These functions should return 0 on success, and take an object as a parameter.

Parameters:
hmap hmap object
f function
Returns:
0 on success, non-zero on failure

Definition at line 569 of file hmap.c.

int u_hmap_free u_hmap_t *  hmap  ) 
 

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.

Parameters:
hmap hmap object
Returns:
0 on success, non-zero on failure

Definition at line 600 of file hmap.c.

References u_free().

int u_hmap_get u_hmap_t *  hmap,
const char *  key,
void **  val
 

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.

Parameters:
hmap hmap object
key key to be retrieved
val returned value
Returns:
0 on success, non-zero on failure

Definition at line 532 of file hmap.c.

int u_hmap_new u_hmap_opts_t opts,
u_hmap_t **  hmap
 

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.

Parameters:
opts options to be passed to the hmap
hmap on success contains the hmap options object
Returns:
0 on success, non-zero on failure

Definition at line 181 of file hmap.c.

References u_free(), u_hmap_opts_new(), and u_zalloc().

int u_hmap_opts_new u_hmap_opts_t **  opts  ) 
 

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.

Parameters:
opts on success contains the hmap options object
Returns:
0 on success, non-zero on failure

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().

int u_hmap_put u_hmap_t *  hmap,
const char *  key,
void *  val
 

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.

Parameters:
hmap hmap object
key key to be inserted
val value to be inserted
Returns:
0 on success, non-zero on failure

Definition at line 461 of file hmap.c.


←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved