ARRAY: add getter's to retrieve number of bins and elms/bin

Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
Angus Salkeld 2011-04-14 09:55:57 +10:00
parent 0d345d3ef1
commit 4de5ff927f
2 changed files with 26 additions and 0 deletions

View File

@ -72,6 +72,16 @@ int32_t qb_array_index(qb_array_t* a, int32_t idx, void** element_out);
*/
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.
* @param a array instance.

View File

@ -84,6 +84,22 @@ int32_t qb_array_index(struct qb_array* a, int32_t idx, void** element_out)
return 0;
}
size_t qb_array_num_bins_get(struct qb_array* a)
{
if (a == NULL) {
return -EINVAL;
}
return a->num_bins;
}
size_t qb_array_elems_per_bin_get(struct qb_array* a)
{
if (a == NULL) {
return -EINVAL;
}
return MAX_BIN_ELEMENTS;
}
int32_t qb_array_grow(struct qb_array* a, size_t max_elements)
{
int32_t i;