memory_arena
Loading...
Searching...
No Matches
Functions | Variables
arena_debug.c File Reference

Debugging, error reporting, memory poisoning, and integrity checking utilities for the Arena memory allocation system. More...

#include "arena_debug.h"
#include "arena.h"
#include "arena_stats.h"
#include <stdarg.h>
#include <stdatomic.h>
#include <stdio.h>
#include <string.h>
+ Include dependency graph for arena_debug.c:

Go to the source code of this file.

Functions

void arena_default_error_callback (const char *msg, void *ctx)
 Default fallback error callback (prints to stderr).
 
void arena_generate_id (t_arena *arena)
 Generate a unique debug ID for an arena.
 
void arena_report_error (t_arena *arena, const char *fmt,...)
 Report an error from an arena using its configured error callback.
 
void arena_set_debug_label (t_arena *arena, const char *label)
 Assign a debug label to an arena.
 
void arena_set_error_callback (t_arena *arena, arena_error_callback cb, void *context)
 Set a custom error callback function for reporting arena errors.
 

Variables

static atomic_int g_arena_id_counter = 0
 Global atomic counter for generating unique arena IDs.
 

Detailed Description

Debugging, error reporting, memory poisoning, and integrity checking utilities for the Arena memory allocation system.

Author
Toonsa
Date
2025

This module provides diagnostic tools and debug features for tracking arena state, reporting errors, and catching incorrect memory usage patterns. It includes:

All features are modular and gated by compile-time flags to avoid overhead in release builds:

These utilities are intended to support:

Note
The debug system is opt-in and safe for multithreaded use when enabled. For minimal runtime cost, features can be selectively toggled via macros.

Definition in file arena_debug.c.