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

The process-wide allocator table used for all of infix's internal heap allocations. More...

#include "common/infix_internals.h"
#include <stdlib.h>
Include dependency graph for allocator.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void infix_set_allocator (const infix_allocator_t *allocator)
 Replaces the allocator infix uses for all internal heap allocations.
 

Variables

infix_allocator_t infix_allocator = {malloc, calloc, realloc, free}
 The allocator currently used for all of infix's internal heap allocations.
 

Detailed Description

The process-wide allocator table used for all of infix's internal heap allocations.

Copyright (c) 2025 Sanko Robinson

This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.

SPDX-License-Identifier: (Artistic-2.0 OR MIT)

Every internal allocation is routed through infix_allocator (see the infix_* memory macros in infix.h). By default the table points at the C library's malloc/calloc/realloc/free, so out of the box infix behaves exactly as it always has. Host applications can install their own allocator with infix_set_allocator() (e.g. a language runtime's tracked heap) so that every block infix allocates and returns to the host comes from a single, known allocator.