qbarray.h File Reference
This is a dynamic array (it can grow, but without moving memory).
More...
#include <stdint.h>
#include <unistd.h>
#include <qb/qbdefs.h>
Detailed Description
This is a dynamic array (it can grow, but without moving memory).
Typedef Documentation
This is an opaque data type representing an instance of an array.
- Examples:
- ipcserver.c.
Function Documentation
qb_array_t* qb_array_create |
( |
size_t |
max_elements, |
|
|
size_t |
element_size | |
|
) |
| | |
Create an array with fixed sized elements.
- Parameters:
-
| max_elements | initial max elements. |
| element_size | size of each element. |
- Returns:
- array instance.
qb_array_t* qb_array_create_2 |
( |
size_t |
max_elements, |
|
|
size_t |
element_size, |
|
|
size_t |
autogrow_elements | |
|
) |
| | |
Create an array with fixed sized elements.
- Parameters:
-
| max_elements | initial max elements. |
| element_size | size of each element. |
| autogrow_elements | the number of elements to grow automatically by. |
- Returns:
- array instance.
- Examples:
- ipcserver.c.
size_t qb_array_elems_per_bin_get |
( |
qb_array_t * |
a |
) |
|
Get the number of elements per bin.
Free all the memory used by the array.
- Parameters:
-
int32_t qb_array_grow |
( |
qb_array_t * |
a, |
|
|
size_t |
max_elements | |
|
) |
| | |
Grow the array.
- Parameters:
-
| a | array instance. |
| max_elements | the new maximum size of the array. |
- Returns:
- (0 == success, else -errno)
int32_t qb_array_index |
( |
qb_array_t * |
a, |
|
|
int32_t |
idx, |
|
|
void ** |
element_out | |
|
) |
| | |
Get an element at a particular index.
- Parameters:
-
| a | array instance. |
| idx | the index |
| element_out | the pointer to the element data. |
- Returns:
- (0 == success, else -errno)
- Examples:
- ipcserver.c.
Get a callback when a new bin is allocated.
Get the number of bins used or the array.