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

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

#include "common/double_tap.h"
#include "core/arena.c"
#include <infix/infix.h>
#include <stdint.h>
#include <string.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 tests for the internal arena allocator.

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)

The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

SPDX-License-Identifier: CC-BY-4.0

This test validates the core functionality of the arena (bump) allocator in isolation. It verifies:

  1. Correct creation and destruction of the arena.
  2. That infix_arena_alloc returns non-nullptr pointers for valid requests.
  3. That pointers returned by infix_arena_alloc are correctly aligned.
  4. That infix_arena_calloc returns zero-initialized memory.
  5. That the allocator correctly detects out-of-memory conditions and returns nullptr without crashing when the arena's capacity is exceeded.

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:132