4.2 Data Structures
/* Memory allocation header (debug builds only) */
typedef struct {
size_t size; /* Allocation size */
const char *file; /* Source file */
int line; /* Source line */
const char *function; /* Function name */
uint32_t magic; /* Magic number for validation */
uint32_t checksum; /* Checksum for leak detection */
} d3tui_alloc_header_t;
/* Memory statistics */
typedef struct {
size_t total_allocated; /* Total bytes allocated */
size_t total_freed; /* Total bytes freed */
size_t current_usage; /* Current bytes in use */
size_t peak_usage; /* Peak bytes in use */
size_t allocation_count; /* Number of allocations */
size_t free_count; /* Number of frees */
} d3tui_memory_stats_t;
/* Memory manager */
typedef struct {
d3tui_memory_stats_t stats; /* Memory statistics */
bool debug_enabled; /* Debug mode enabled */
} d3tui_memory_manager_t;