SimGrid: Mallocator object handling

SimGrid 3.10 Versatile Simulation of Distributed Systems

- Home page
- Online documentation
- Dev's Corner

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
Mallocator object handling
Mallocators

## Functions
void * | xbt_mallocator_get (xbt_mallocator_t mallocator)
| Extract an object from a mallocator.
void | xbt_mallocator_release (xbt_mallocator_t mallocator, void *object)
| Push an object into a mallocator.
void | xbt_mallocator_initialization_is_done (int protect)

## Detailed Description

## Function Documentation

void* xbt_mallocator_get | ( | xbt_mallocator_t | m | ) |

Extract an object from a mallocator.

Parameters

  m | a 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

  m | a mallocator
  object | an 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