Arena allocation make deallocation of nested structed MUCH faster, and improves the spatial locality of allocations. It makes no sense to deallocate only parts of a JSON structure so arenas are a good fit here.
16 lines
348 B
C
16 lines
348 B
C
|
|
#ifndef _UTIL_H
|
|
#define _UTIL_H
|
|
|
|
#include <stddef.h> // size_t
|
|
#include <stdio.h> // FILE*
|
|
|
|
__attribute__((__noreturn__)) void err_ctx(int exit_code, FILE* fp, const char* format, ...);
|
|
|
|
void* malloc_or_die(size_t size);
|
|
void* realloc_or_die(void* ptr, size_t size);
|
|
void* calloc_or_die(size_t nmemb, size_t size);
|
|
void print_trace(void);
|
|
|
|
#endif
|