Cthulhu  0.2.10
Cthulhu compiler collection
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
arena.h File Reference
#include <ctu_arena_api.h>
#include <ctu_config.h>
#include "core/analyze.h"
#include "core/compiler.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
Include dependency graph for arena.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  arena_t
 an allocator object More...
 

Macros

#define CTU_TRACE_MEMORY   0
 a compile time flag to enable memory tracing More...
 
#define CT_ALLOC_SIZE_UNKNOWN   SIZE_MAX
 unknown allocation size constant when freeing or reallocating memory, this can be used as the size to indicate that the size is unknown. requires allocator to support this. More...
 
#define ARENA_RENAME(arena, ptr, name)
 rename a pointer in a custom allocator More...
 
#define ARENA_REPARENT(arena, ptr, parent)
 reparent a pointer in a custom allocator More...
 
#define ARENA_MALLOC(size, name, parent, arena)   arena_malloc(size, arena)
 allocate memory from a custom allocator More...
 
#define ARENA_OPT_MALLOC(size, name, parent, arena)   arena_opt_malloc(size, arena)
 
#define ARENA_IDENTIFY(ptr, name, parent, arena)
 rename and reparent a pointer in a custom allocator More...
 

Typedefs

typedef void *(* mem_alloc_t) (size_t size, void *user)
 arena malloc callback More...
 
typedef void *(* mem_resize_t) (void *ptr, size_t new_size, size_t old_size, void *user)
 arena realloc callback More...
 
typedef void(* mem_release_t) (void *ptr, size_t size, void *user)
 arena free callback More...
 
typedef void(* mem_rename_t) (const void *ptr, const char *name, void *user)
 arena rename callback More...
 
typedef void(* mem_reparent_t) (const void *ptr, const void *parent, void *user)
 arena reparent callback More...
 

Functions

CT_ARENA_API void arena_free (STA_RELEASE void *ptr, size_t size, arena_t *arena)
 release memory from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API void * arena_malloc (size_t size, arena_t *arena)
 allocate memory from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API void * arena_malloc_info (size_t size, const char *name, const void *parent, arena_t *arena)
 allocate memory from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API void * arena_realloc (STA_RELEASE void *ptr, size_t new_size, size_t old_size, arena_t *arena)
 resize a memory allocation from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API char * arena_strdup (const char *str, arena_t *arena)
 allocate a copy of a string from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API char * arena_strndup (STA_READS(len) const char *str, size_t len, arena_t *arena)
 allocate a copy of a string with a maximum length from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API void * arena_memdup (STA_READS(size) const void *ptr, size_t size, arena_t *arena)
 duplicate a memory region from a custom allocator duplicate a region of memory and return a pointer to the new memory. More...
 
CT_ARENA_API void arena_opt_free (STA_RELEASE void *ptr, size_t size, arena_t *arena)
 release memory from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API void * arena_opt_malloc (size_t size, arena_t *arena)
 allocate memory from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API void * arena_opt_malloc_info (size_t size, const char *name, const void *parent, arena_t *arena)
 allocate memory from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API void * arena_opt_realloc (STA_RELEASE void *ptr, size_t new_size, size_t old_size, arena_t *arena)
 resize a memory allocation from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API char * arena_opt_strdup (const char *str, arena_t *arena)
 allocate a copy of a string from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API char * arena_opt_strndup (STA_READS(len) const char *str, size_t len, arena_t *arena)
 allocate a copy of a string with a maximum length from a custom allocator More...
 
CT_NODISCARD CT_ARENA_API void * arena_opt_memdup (STA_READS(size) const void *ptr, size_t size, arena_t *arena)
 duplicate a memory region from a custom allocator duplicate a region of memory and return a pointer to the new memory. More...
 
CT_NODISCARD CT_ARENA_API void * arena_data (arena_t *arena)
 get the user data pointer from an arena More...
 
CT_ARENA_API void arena_rename (const void *ptr, const char *name, arena_t *arena)
 rename a pointer in a custom allocator More...
 
CT_ARENA_API void arena_reparent (const void *ptr, const void *parent, arena_t *arena)
 reparent a pointer in a custom allocator More...