Allocation from one caller-owned process-wide memory region.
More...
Allocation from one caller-owned process-wide memory region.
SGL does not fall back to the C runtime heap. Initialize the pool before creating LUTs, queues, thread pools, or invoking an operation that needs temporary storage. Initialization and deinitialization are not concurrent operations; allocation and release are synchronized after initialization.
◆ sgl_calloc()
Allocates and zero-initializes an array from the SGL memory pool.
- Parameters
-
| [in] | count | Number of elements. |
| [in] | size | Size of one element in bytes. |
- Returns
- Zero-filled memory, or SGL_NULL when the request cannot be served.
◆ sgl_free()
| void sgl_free |
( |
void * |
memory | ) |
|
Releases a block allocated by sgl_malloc() or sgl_calloc().
- Parameters
-
| [in,out] | memory | Allocation to release; SGL_NULL is accepted. |
- Note
- Pointers outside the active pool are ignored. Each live allocation must be released exactly once; a previously released pointer is invalid.
◆ sgl_malloc()
Allocates an aligned block from the SGL memory pool.
- Parameters
-
| [in] | size | Requested size in bytes. |
- Returns
- Allocated memory, or SGL_NULL for zero size, an uninitialized pool, overflow, or insufficient free space.
◆ sgl_memory_pool_deinitialize()
Detaches the caller-owned memory pool.
- Return values
-
| SGL_SUCCESS | No live allocations remain and the pool was detached. |
| SGL_FAILURE | At least one allocation is still live. |
| SGL_ERROR_INVALID_ARGUMENTS | The pool is not initialized. |
◆ sgl_memory_pool_initialize()
Registers the process-wide SGL memory pool.
- Parameters
-
| [in,out] | memory | Caller-owned storage retained until deinitialization. |
| [in] | size | Size of memory in bytes, including allocator metadata. |
- Return values
-
| SGL_SUCCESS | Pool initialized successfully. |
| SGL_ERROR_INVALID_ARGUMENTS | Invalid storage, insufficient size, or an already initialized pool. |
- Note
- The implementation aligns the usable range inside the supplied buffer.