|
Derive-C
|
#include <derive-c/core/includes/def.h>#include "includes.h"#include <derive-c/core/alloc/def.h>#include <derive-c/core/self/def.h>#include <derive-c/alloc/std.h>#include <derive-c/container/map/swiss/template.h>#include <derive-c/core/self/undef.h>#include <derive-c/core/alloc/undef.h>#include <derive-c/core/includes/undef.h>Go to the source code of this file.
Data Structures | |
| struct | SELF |
| An allocator that prints to stdout when it allocates or frees memory. More... | |
Macros | |
| #define | ALLOCATIONS_MAP NS(NAME, allocations) |
| For unit tests expected to throw, as C has no unwind, we cannot free allocated memory. This macro wraps the allocator in debug, to allow clearing leaks after an exception. | |
| #define | ALLOC stdalloc |
| #define | KEY void* |
| #define | KEY_HASH(ptr) |
| #define | KEY_DEBUG dc_void_ptr_debug |
| #define | VALUE size_t |
| #define | INTERNAL_NAME ALLOCATIONS_MAP |
Functions | |
| static DC_PUBLIC SELF | new (ref alloc_ref) |
| static DC_PUBLIC ALLOCATIONS_MAP const * | get_allocations (SELF const *self) |
| static DC_PUBLIC void | delete (SELF *self) |
| static DC_PUBLIC void | unleak (SELF *self) |
| static DC_PUBLIC void * | allocate_zeroed (SELF *self, size_t size) |
| static DC_PUBLIC void * | allocate_uninit (SELF *self, size_t size) |
| static DC_PUBLIC void * | reallocate (SELF *self, void *old_ptr, size_t old_size, size_t new_size) |
| static DC_PUBLIC void | deallocate (SELF *self, void *ptr, size_t size) |
| static DC_PUBLIC void | debug (SELF const *self, dc_debug_fmt fmt, FILE *stream) |
| DC_TRAIT_REFERENCABLE_BY_PTR (SELF) | |
| DC_TRAIT_ALLOC (SELF) | |
| #define ALLOC stdalloc |
Definition at line 31 of file template.h.
For unit tests expected to throw, as C has no unwind, we cannot free allocated memory. This macro wraps the allocator in debug, to allow clearing leaks after an exception.
In release, it is a no-op / pass through.
As this is entirely C, we do not get the niceties of a C++ RAII allocator guard shebang. However, this is usable inside unit tests written in C.
Definition at line 25 of file template.h.
| #define INTERNAL_NAME ALLOCATIONS_MAP |
Definition at line 36 of file template.h.
| #define KEY void* |
Definition at line 32 of file template.h.
| #define KEY_DEBUG dc_void_ptr_debug |
Definition at line 34 of file template.h.
| #define KEY_HASH | ( | ptr | ) |
Definition at line 33 of file template.h.
| #define VALUE size_t |
Definition at line 35 of file template.h.
Definition at line 78 of file template.h.
Definition at line 68 of file template.h.
| DC_TRAIT_ALLOC | ( | SELF | ) |
| DC_TRAIT_REFERENCABLE_BY_PTR | ( | SELF | ) |
Definition at line 110 of file template.h.
|
static |
Definition at line 126 of file template.h.
Definition at line 58 of file template.h.
|
static |
Definition at line 53 of file template.h.
Definition at line 46 of file template.h.
|
static |
Definition at line 88 of file template.h.
Definition at line 62 of file template.h.