C Collections

cmempool · Section 3

crmempool_create

crmempool_create - create a ranged memory pool

C Collections (libccollections, -lccollections)

#include <ccollections/cmempool.h>
 
crmempool_create(smallest_size_power_of_two, largest_size_power_of_two,
                 number_of_smallest_size_elems_power_of_two,
                 fb_policy, single_threaded, err);

Creates a ranged memory pool, which manages several fixed-size pools
of power-of-2 sizes and picks the right one for each allocation
request. The pool's own memory and its fallback entries come from the
standard malloc and free.
 
It is the same as calling crmempool_create_mp() with NULL memory
management procedures, and every rule of that page applies.

smallest_size_power_of_two                  Exponent for smallest pool size
largest_size_power_of_two                   Exponent for largest pool size
number_of_smallest_size_elems_power_of_two  Exponent for smallest pool count
fb_policy                                   Fallback policy for an empty pool
single_threaded                             If true, take no lock
err                                         Optional pointer that receives
                                            an error string

Returns a pointer to the new ranged memory pool on success
Returns NULL on failure

The caller must destroy the pool with crmempool_destroy().

crmempool_create_mp(3), crmempool_create_from_preallocated_buffer(3), crmempool_destroy(3)