Arrays which store name/value pair items, and can grow unlimited.
More...
|
#define | ci_dyn_array_get_item(array, pos) (pos < (array)->count ? (array)->items[pos] : NULL) |
| Return the ci_array_item_t item on position 'pos'.
|
|
#define | ci_dyn_array_value(array, pos) ((pos < (array)->count && (array)->items[pos] != NULL) ? (array)->items[pos]->value : NULL) |
| Return the value of item on position 'pos'.
|
|
#define | ci_dyn_array_name(array, pos) ((pos < (array)->count && (array)->items[pos] != NULL) ? (array)->items[pos]->name : NULL) |
| Return the name of item on position 'pos'.
|
|
#define | ci_dyn_array_size(array) ((array)->count) |
| Return the size of array 'array'.
|
|
|
typedef struct ci_dyn_array | ci_dyn_array_t |
| The ci_dyn_array_t objects can store a list of name/value pairs. More...
|
|
Arrays which store name/value pair items, and can grow unlimited.
The ci_dyn_array_t objects can store a list of name/value pairs.
The memory RAM space of dynamic array items can not be released before the ci_dyn_array destroyed.
const ci_array_item_t* ci_dyn_array_add |
( |
ci_dyn_array_t * |
array, |
|
|
const char * |
name, |
|
|
const void * |
value, |
|
|
size_t |
size |
|
) |
| |
Add an name/value pair item to a dynamic array.
- Parameters
-
array | a pointer to the ci_dyn_array_t object |
name | the name part of the name/value pair item to be added |
value | the value part of the name/value pair item to be added |
size | the size of the value part of the new item. |
- Returns
- a pointer to the new array item on success, NULL otherwise
Destroy an ci_dyn_array_t object.
- Parameters
-
array | a pointer to ci_dyn_array_t object to be destroyed |
void ci_dyn_array_iterate |
( |
const ci_dyn_array_t * |
array, |
|
|
void * |
data, |
|
|
int(*)(void *data, const char *name, const void *) |
fn |
|
) |
| |
Run the given function for each dynamic array item.
- Parameters
-
array | a pointer to the ci_dyn_array_t object |
data | a pointer to data which will be passed on fn function |
fn | a pointer to the function which will be run for each array item. The iteration will stop if the fn function return non zero value. |
Allocate the required memory and initialize an ci_dyn_array_t object.
- Parameters
-
mem_size | the initial size to use for dyn_array |
- Returns
- the allocated object on success, or NULL on failure
Create and initialize an ci_dyn_array_t object for the given number of items.
- Parameters
-
items | the maximum aray items |
item_size | the items size |
- Returns
- the allocated object on success, or NULL on failure
const void* ci_dyn_array_search |
( |
ci_dyn_array_t * |
array, |
|
|
const char * |
name |
|
) |
| |
Search in an dynamic array for an item with the given name.
- Parameters
-
array | a pointer to the ci_dyn_array_t object |
name | the item to be search for. |
- Returns
- pointer to the value pair of the array item if found, NULL otherwise