infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
Ch08_CustomAllocators.c File Reference

Cookbook Chapter 8: Using Custom Memory Allocators. More...

#include <stdio.h>
#include <stdlib.h>
#include <infix/infix.h>
Include dependency graph for Ch08_CustomAllocators.c:

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
 

Detailed Description

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.

Macro Definition Documentation

◆ infix_free

#define infix_free (   ptr)    tracking_free(ptr)

◆ infix_malloc

#define infix_malloc (   size)    tracking_malloc(size)

Function Documentation

◆ dummy_func()

void dummy_func ( )

◆ main()

int main ( void  )

◆ tracking_free()

void tracking_free ( void *  ptr)

◆ tracking_malloc()

void * tracking_malloc ( size_t  size)

Variable Documentation

◆ g_total_allocated

size_t g_total_allocated = 0
static