SimGrid  3.13
Versatile Simulation of Distributed Systems
Mallocator object handling

Functions

voidxbt_mallocator_get (xbt_mallocator_t mallocator)
 Extract an object from a mallocator. More...
 
void xbt_mallocator_release (xbt_mallocator_t mallocator, void *object)
 Push an object into a mallocator. More...
 
void xbt_mallocator_initialization_is_done (int protect)
 This function must be called once the framework configuration is done. More...
 

Detailed Description

Function Documentation

void* xbt_mallocator_get ( xbt_mallocator_t  m)

Extract an object from a mallocator.

Parameters
ma mallocator

Remove an object from the mallocator and return it. This function is designed to be used instead of malloc(). If the mallocator is not empty, an object is extracted from the mallocator and no malloc is done.

If the mallocator is empty, a new object is created, by calling the function new_f().

In both cases, the function reset_f() (if defined) is called on the object.

See also
xbt_mallocator_release()
void xbt_mallocator_release ( xbt_mallocator_t  m,
void object 
)

Push an object into a mallocator.

Parameters
ma mallocator
objectan object you don't need anymore

Push into the mallocator an object you don't need anymore. This function is designed to be used instead of free(). If the mallocator is not full, your object if stored into the mallocator and no free is done. If the mallocator is full, the object is freed by calling the function free_f().

See also
xbt_mallocator_get()
void xbt_mallocator_initialization_is_done ( int  protect)

This function must be called once the framework configuration is done.

If not, mallocators will never get used. Check the implementation notes in src/xbt/mallocator.c for the justification of this.

For example, surf_config uses this function to tell to the mallocators that the simgrid configuration is now finished and that it can create them if not done yet