mirror of
https://salsa.debian.org/ha-team/libqb
synced 2026-08-17 16:18:17 +00:00
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:
parent
0d345d3ef1
commit
4de5ff927f
@ -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.
|
||||
|
||||
16
lib/array.c
16
lib/array.c
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user