A small, freestanding-friendly allocation interface used across LibJuno. Concrete allocators (such as the fixed-size block allocator) implement this vtable. Callers interact only through the root's API pointer.
Core concepts:
- Pointers are described by JUNO_POINTER_T, which carries an address, size, alignment, and a pointer-operations API (Copy/Reset). See Pointer API.
- The allocator root (JUNO_MEMORY_ALLOC_ROOT_T) stores the allocator API (this vtable) and the dependent pointer API used by the allocator.
- All operations return explicit status codes; no hidden dynamic allocation.
Contract summary:
- Get(ptMem, zSize): allocates a region of at least zSize bytes and returns a result carrying a JUNO_POINTER_T on success. zSize must be
0 and must satisfy allocator-specific bounds (e.g., <= element size in a block allocator). On failure, tStatus != JUNO_STATUS_SUCCESS and tOk is unspecified (do not use).
- Update(ptMem, ptMemory, zNewSize): adjusts the size field of an existing allocation when supported by the allocator. For the fixed block allocator, this only shrinks or sets size up to the element size; it does not move memory. Returns JUNO_STATUS_MEMALLOC_ERROR if zNewSize exceeds limits.
- Put(ptMem, ptMemory): frees a previously allocated region. On success, the descriptor is cleared (pvAddr=NULL, zSize=zAlignment=0). Errors such as double free, invalid address, or misalignment are reported with JUNO_STATUS_MEMFREE_ERROR and the descriptor is restored to its original value.
◆ JunoMemory_AllocApiVerify()
Verify that a memory allocator API provides required functions.
- Parameters
-
| ptAllocApi | API vtable to check. |
- Returns
- JUNO_STATUS_SUCCESS if valid; error otherwise.
◆ JunoMemory_AllocVerify()
Verify a memory allocator instance and its dependent pointer API.
- Parameters
-
| ptAlloc | Allocator root object to verify. |
- Returns
- JUNO_STATUS_SUCCESS if valid; error otherwise.