|
infix
A JIT-Powered FFI Library for C
|
Cookbook Chapter 8: Using Custom Memory Allocators. More...
Macros | |
| #define | infix_malloc(size) tracking_malloc(size) |
| #define | infix_free(ptr) tracking_free(ptr) |
Functions | |
| void * | tracking_malloc (size_t size) |
| void | tracking_free (void *ptr) |
| void | dummy_func () |
| int | main () |
Variables | |
| static size_t | g_total_allocated = 0 |
Cookbook Chapter 8: Using Custom Memory Allocators.
This example demonstrates how to integrate infix with a custom memory manager. This is useful for applications that need to track allocations, use a memory pool, or integrate with a garbage collector.
The mechanism is simple: define the infix_malloc, infix_free, etc., macros before including infix.h. All internal memory operations in the library will then be redirected to your custom functions.
| #define infix_free | ( | ptr | ) | tracking_free(ptr) |
| #define infix_malloc | ( | size | ) | tracking_malloc(size) |
| void dummy_func | ( | ) |
| int main | ( | void | ) |
| void tracking_free | ( | void * | ptr | ) |
| void * tracking_malloc | ( | size_t | size | ) |
|
static |