qbarray.h (3) - Linux Manuals
NAME
qbarray.h -
This is a dynamic array (it can grow, but without moving memory).
SYNOPSIS
#include <stdint.h>
#include <unistd.h>
#include <qb/qbdefs.h>
Typedefs
typedef struct qb_array qb_array_t
This is an opaque data type representing an instance of an array.
typedef void(* qb_array_new_bin_cb_fn )(qb_array_t *a, uint32_t bin)
Functions
qb_array_t * qb_array_create (size_t max_elements, size_t element_size)
Create an array with fixed sized elements.
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.
int32_t qb_array_index (qb_array_t *a, int32_t idx, void **element_out)
Get an element at a particular index.
int32_t qb_array_grow (qb_array_t *a, size_t max_elements)
Grow the array.
size_t qb_array_num_bins_get (qb_array_t *a)
Get the number of bins used or the array.
size_t qb_array_elems_per_bin_get (qb_array_t *a)
Get the number of elements per bin.
int32_t qb_array_new_bin_cb_set (qb_array_t *a, qb_array_new_bin_cb_fn fn)
Get a callback when a new bin is allocated.
void qb_array_free (qb_array_t *a)
Free all the memory used by the array.
Detailed Description
This is a dynamic array (it can grow, but without moving memory).
* arr = qb_array_create_2(64, sizeof(struct my_struct), 256); * ... * res = qb_array_index(arr, idx, (void**)&my_ptr); * if (res < 0) { * return res; * } * // use my_ptr, now even if there is a grow, this pointer will be valid. *
This is an opaque data type representing an instance of an array.
Create an array with fixed sized elements.
Parameters:
Returns:
Create an array with fixed sized elements.
Parameters:
Returns:
Get the number of elements per bin.
Free all the memory used by the array.
Parameters:
Grow the array.
Parameters:
Returns:
Get an element at a particular index.
Parameters:
Returns:
Get a callback when a new bin is allocated.
Get the number of bins used or the array.
Generated automatically by Doxygen for libqb from the source code.
Typedef Documentation
typedef void(* qb_array_new_bin_cb_fn)(qb_array_t *a, uint32_t bin)
typedef struct qb_array qb_array_t
Function Documentation
qb_array_t* qb_array_create (size_tmax_elements, size_telement_size)
element_size size of each element.
qb_array_t* qb_array_create_2 (size_tmax_elements, size_telement_size, size_tautogrow_elements)
element_size size of each element.
autogrow_elements the number of elements to grow automatically by.
size_t qb_array_elems_per_bin_get (qb_array_t *a)
void qb_array_free (qb_array_t *a)
int32_t qb_array_grow (qb_array_t *a, size_tmax_elements)
max_elements the new maximum size of the array.
int32_t qb_array_index (qb_array_t *a, int32_tidx, void **element_out)
idx the index
element_out the pointer to the element data.
int32_t qb_array_new_bin_cb_set (qb_array_t *a, qb_array_new_bin_cb_fnfn)
size_t qb_array_num_bins_get (qb_array_t *a)
Author