SimGrid  3.14.159
Versatile Simulation of Distributed Systems
Mallocator constructor and destructor

Detailed Description

Typedefs

typedef struct s_xbt_mallocatorxbt_mallocator_t
 Mallocator data type (opaque structure) More...
 

Functions

xbt_mallocator_t xbt_mallocator_new (int size, pvoid_f_void_t new_f, void_f_pvoid_t free_f, void_f_pvoid_t reset_f)
 Constructor. More...
 
void xbt_mallocator_free (xbt_mallocator_t mallocator)
 Destructor. More...
 

Typedef Documentation

◆ xbt_mallocator_t

Mallocator data type (opaque structure)

Function Documentation

◆ xbt_mallocator_new()

xbt_mallocator_t xbt_mallocator_new ( int  size,
pvoid_f_void_t  new_f,
void_f_pvoid_t  free_f,
void_f_pvoid_t  reset_f 
)

Constructor.

Parameters
sizesize of the internal stack: number of objects the mallocator will be able to store
new_ffunction to allocate a new object of your datatype, called in xbt_mallocator_get() when the mallocator is empty
free_ffunction to free an object of your datatype, called in xbt_mallocator_release() when the stack is full, and when the mallocator is freed.
reset_ffunction to reinitialise an object of your datatype, called when you extract an object from the mallocator (can be NULL)

Create and initialize a new mallocator for a given datatype.

Returns
pointer to the created mallocator
See also
xbt_mallocator_free()

◆ xbt_mallocator_free()

void xbt_mallocator_free ( xbt_mallocator_t  m)

Destructor.

Parameters
mthe mallocator you want to destroy

Destroy the mallocator and all its data. The function free_f is called on each object in the mallocator.

See also
xbt_mallocator_new()