LibCapy - memoryPool

Memory pool generic class.

Macros:

Generic memory pool class. Declaration macro for a memory pool of a given type. The definition of the type must include CapyMemPoolFields (see below).

Macro to add necessary fields to a structure to make it usable with CapyMemPool

Create a memory pool

Output and side effect(s):

Return an empty memory pool

Allocate a memory pool

Output and side effect(s):

Return an empty memory pool

Flush and destruct a memory pool

Input argument(s):

that: the memory pool to destruct

Flush and free a memory pool

Input argument(s):

that: the memory pool to free

Alloc memory using the memory pool

Input argument(s):

initElem: if not null the allocated memory is initialized with initElem, must be of size sizeElem bytes

Output and side effect(s):

Return a 'new' element from the pool. If there was a free one, it is reused, else a new element is allocated and added to the pool before returning it.

Free an element allocated using the pool

Input argument(s):

elem: pointer to the element to free

Output and side effect(s):

The element is marked as free to reuse in the memory pool. The destructor is applied to the element.

Flush a memory pool

Output and side effect(s):

All the elements in the pool are freed (their memory is released using the standard 'free' function). The destructor is applied to all remaining element in the pool

Definition macro for a memory pool of a given type.

Enumerations:

None.

Typedefs:

None.

Functions:

None.

2022-10-07
in LibCapy,
47 views
Copyright 2021-2024 Baillehache Pascal