APIs for memory management, including custom allocators and arenas.
More...
|
| #define | infix_malloc malloc |
| | A macro that can be defined to override the default malloc function.
|
| |
| #define | infix_calloc calloc |
| | A macro that can be defined to override the default calloc function.
|
| |
| #define | infix_realloc realloc |
| | A macro that can be defined to override the default realloc function.
|
| |
| #define | infix_free free |
| | A macro that can be defined to override the default free function.
|
| |
| #define | infix_memcpy memcpy |
| | A macro that can be defined to override the default memcpy function.
|
| |
| #define | infix_memset memset |
| | A macro that can be defined to override the default memset function.
|
| |
APIs for memory management, including custom allocators and arenas.
◆ infix_calloc
| #define infix_calloc calloc |
A macro that can be defined to override the default calloc function.
◆ infix_free
A macro that can be defined to override the default free function.
◆ infix_malloc
| #define infix_malloc malloc |
A macro that can be defined to override the default malloc function.
If you need to integrate infix with a custom memory allocator (e.g., for memory tracking or garbage collection), define this macro before including infix.h. You must also define the other infix_* memory macros.
#define infix_malloc my_custom_malloc
#define infix_calloc my_custom_calloc
#define infix_free my_custom_free
#define infix_realloc my_custom_realloc
The public interface for the infix FFI library.
◆ infix_memcpy
| #define infix_memcpy memcpy |
A macro that can be defined to override the default memcpy function.
◆ infix_memset
| #define infix_memset memset |
A macro that can be defined to override the default memset function.
◆ infix_realloc
| #define infix_realloc realloc |
A macro that can be defined to override the default realloc function.
◆ infix_arena_alloc()
Allocates a block of memory from an arena.
- Parameters
-
| [in] | arena | The arena to allocate from. |
| [in] | size | The number of bytes to allocate. |
| [in] | alignment | The required alignment for the allocation. Must be a power of two. |
- Returns
- A pointer to the allocated memory, or
nullptr on failure.
◆ infix_arena_calloc()
Allocates and zero-initializes a block of memory from an arena.
- Parameters
-
| [in] | arena | The arena to allocate from. |
| [in] | num | The number of elements. |
| [in] | size | The size of each element. |
| [in] | alignment | The required alignment. Must be a power of two. |
- Returns
- A pointer to the zero-initialized memory, or
nullptr on failure.
◆ infix_arena_create()
Creates a new memory arena.
An arena is a fast, region-based allocator. All objects allocated from it are freed at once when the arena is destroyed. This is the required mechanism for creating types for the Manual API.
- Parameters
-
| [in] | initial_size | The initial capacity of the arena in bytes. |
- Returns
- A pointer to the new arena, or
nullptr on failure. The caller must free this with infix_arena_destroy.
◆ infix_arena_destroy()
Destroys an arena and frees all memory allocated from it.
- Parameters
-
| [in] | arena | The arena to destroy. Safe to call with nullptr. |