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 <infix/infix.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for Ch08_CustomAllocators.c:

Functions

static void * tracking_malloc (size_t size)
 
static 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 recommended mechanism is infix_set_allocator(), which redirects all of infix's internal heap allocations to your callbacks at runtime. (A compile-time alternative, defining the infix_malloc/infix_free/etc. macros before including infix.h, is also supported for builds from source.)

Function Documentation

◆ dummy_func()

void dummy_func ( )

◆ main()

int main ( void  )

◆ tracking_free()

static void tracking_free ( void *  ptr)
static

◆ tracking_malloc()

static void * tracking_malloc ( size_t  size)
static

Variable Documentation

◆ g_total_allocated

size_t g_total_allocated = 0
static