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

Unit test for the internal arena allocator. More...

#include "common/double_tap.h"
#include <infix/infix.h>
#include <stdint.h>
#include <string.h>
#include "common/infix_internals.h"
Include dependency graph for 840_arena_allocator.c:

Macros

#define infix_malloc   malloc
 
#define infix_calloc   calloc
 
#define infix_free   free
 
#define infix_realloc   realloc
 
#define DBLTAP_IMPLEMENTATION
 

Functions

 subtest ("Arena Allocator Core Functionality")
 

Variables

 TEST
 

Detailed Description

Unit test for the internal arena allocator.

This test file validates the core functionality of the infix_arena_t memory manager. Since the arena allocator is an internal component, this test must include the arena.c source file directly to access its functions. It also defines the infix_* memory macros to use the standard malloc, etc., to avoid interference from the fault-injection allocator in other tests.

The test verifies:

  • Creation/Destruction: infix_arena_create and infix_arena_destroy work as expected.
  • Basic Allocation: infix_arena_alloc returns a valid, non-null pointer.
  • Alignment: A pointer allocated with a specific alignment is correctly aligned.
  • Zeroed Allocation: infix_arena_calloc returns a block of memory that is properly zero-initialized.
  • Error Handling: When an allocation request exceeds the arena's capacity, infix_arena_alloc correctly returns nullptr and sets the arena's internal error flag.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

◆ infix_calloc

#define infix_calloc   calloc

◆ infix_free

#define infix_free   free

◆ infix_malloc

#define infix_malloc   malloc

◆ infix_realloc

#define infix_realloc   realloc

Function Documentation

◆ subtest()

subtest ( "Arena Allocator Core Functionality"  )

Variable Documentation

◆ TEST

TEST
Initial value:
{
plan(1)
#define plan(count)
Definition double_tap.h:163