qbarray.h   qbarray.h 
skipping to change at line 39 skipping to change at line 39
/* *INDENT-OFF* */ /* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
/* *INDENT-ON* */ /* *INDENT-ON* */
/** /**
* @file qbarray.h * @file qbarray.h
* This is a dynamic array (it can grow, but without moving memory). * This is a dynamic array (it can grow, but without moving memory).
*
* @code
* 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.
* @endcode
*/ */
struct qb_array; struct qb_array;
/** /**
* This is an opaque data type representing an instance of an array. * This is an opaque data type representing an instance of an array.
*/ */
typedef struct qb_array qb_array_t; typedef struct qb_array qb_array_t;
/** /**
* Create an array with fixed sized elements. * Create an array with fixed sized elements.
* *
* @param max_elements initial max elements. * @param max_elements initial max elements.
* @param element_size size of each element. * @param element_size size of each element.
* @return array instance. * @return array instance.
*/ */
qb_array_t* qb_array_create(size_t max_elements, size_t element_size); qb_array_t* qb_array_create(size_t max_elements, size_t element_size);
/** /**
* Create an array with fixed sized elements.
*
* @param max_elements initial max elements.
* @param element_size size of each element.
* @param autogrow_elements the number of elements to grow automatically by
.
*
* @return array instance.
*/
qb_array_t* qb_array_create_2(size_t max_elements, size_t element_size,
size_t autogrow_elements);
/**
* Get an element at a particular index. * Get an element at a particular index.
* @param a array instance. * @param a array instance.
* @param idx the index * @param idx the index
* @param element_out the pointer to the element data. * @param element_out the pointer to the element data.
* @return (0 == success, else -errno) * @return (0 == success, else -errno)
*/ */
int32_t qb_array_index(qb_array_t* a, int32_t idx, void** element_out); int32_t qb_array_index(qb_array_t* a, int32_t idx, void** element_out);
/** /**
* Grow the array. * Grow the array.
* *
* @param a array instance. * @param a array instance.
* @param max_elements the new maximum size of the array. * @param max_elements the new maximum size of the array.
* @return (0 == success, else -errno) * @return (0 == success, else -errno)
*/ */
int32_t qb_array_grow(qb_array_t* a, size_t max_elements); int32_t qb_array_grow(qb_array_t* a, size_t max_elements);
/** /**
* Get the number of bins used or the array.
*/
size_t qb_array_num_bins_get(qb_array_t* a);
/**
* Get the number of elements per bin.
*/
size_t qb_array_elems_per_bin_get(qb_array_t* a);
/**
* Free all the memory used by the array. * Free all the memory used by the array.
* @param a array instance. * @param a array instance.
*/ */
void qb_array_free(qb_array_t * a); void qb_array_free(qb_array_t * a);
/* *INDENT-OFF* */ /* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
/* *INDENT-ON* */ /* *INDENT-ON* */
 End of changes. 3 change blocks. 
0 lines changed or deleted 33 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/