|
memory_arena
|
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. | |
Debugging, error reporting, memory poisoning, and integrity checking utilities for the Arena memory allocation system.
This module provides diagnostic tools and debug features for tracking arena state, reporting errors, and catching incorrect memory usage patterns. It includes:
arena_generate_id)arena_set_debug_label)arena_set_error_callback)arena_report_error)arena_poison_memory) to detect use-after-reset bugsarena_integrity_check) for development and testingAll features are modular and gated by compile-time flags to avoid overhead in release builds:
ARENA_DEBUG_CHECKS enables runtime assertions and state validation.ARENA_POISON_MEMORY enables memory poisoning.ARENA_DEBUG_LOG enables optional debug logging via ALOG(...).These utilities are intended to support:
Definition in file arena_debug.c.