C Collections

cmempool · Section 3

crmempool_total_capacity

crmempool_total_capacity - get total capacity for a size

C Collections (libccollections, -lccollections)

#include <ccollections/cmempool.h>
 
size_t crmempool_total_capacity(crmempool *rmp, size_t size);

Returns the total number of entries in the pool that serves the given
size, without any dynamic allocation.

rmp   Ranged memory pool to query
size  Size in bytes to query (maps to a specific sub-pool)

Returns the total capacity for this size
Returns 0 when size is invalid

It returns 0 if size is invalid, which means 0 or above largest_size
It asserts if rmp is NULL
It rounds size up to the next power-of-two pool
Thread-safe if the pool was created with single_threaded=false
 
The count reported for a size is the count that its tier was built
for, and you can always get that many entries of that size. A tier that
is large enough to keep a cache for each thread allocates a reserve
above that count, so concurrent callers can hold a few more than this
for a short while. cmempool_total_capacity(3) gives the full
account.

crmempool_used_count(3), crmempool_dynamic_allocs_count(3)