Go to the source code of this file.
◆ ALLOC
◆ ENTRIES_VECTOR
| #define ENTRIES_VECTOR NS(NAME, entries) |
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 43 of file template.h.
◆ INTERNAL_NAME
◆ ITEM
◆ TRACKED_ENTRY
| #define TRACKED_ENTRY NS(EXPAND(ENTRIES), entry) |
◆ calloc()
| void * calloc |
( |
SELF * | self, |
|
|
size_t | count, |
|
|
size_t | size ) |
|
static |
Definition at line 92 of file template.h.
92 {
95 if (ptr) {
97 .ptr = ptr,
98 .freed = false,
99 });
100 }
101 return ptr;
102}
static void * calloc(SELF *self, size_t count, size_t size)
#define ENTRIES_VECTOR
For unit tests expected to throw, as C has no unwind, we cannot free allocated memory....
static INDEX_TYPE size(SELF const *self)
static ITEM * push(SELF *self, ITEM item)
◆ free()
| void free |
( |
SELF * | self, |
|
|
void * | ptr ) |
|
static |
Definition at line 122 of file template.h.
122 {
125
128
130 if (entry->
ptr == ptr) {
133 break;
134 }
135 }
136
138}
static void free(SELF *self, void *ptr)
static ITER get_iter(SELF *self)
◆ get_entries()
Definition at line 74 of file template.h.
74 {
76 return &self->entries;
77}
◆ malloc()
| void * malloc |
( |
SELF * | self, |
|
|
size_t | size ) |
|
static |
Definition at line 104 of file template.h.
104 {
107 if (ptr) {
109 .ptr = ptr,
110 .freed = false,
111 });
112 }
113 return ptr;
114}
static void * malloc(SELF *self, size_t size)
◆ new()
◆ realloc()
| void * realloc |
( |
SELF * | self, |
|
|
void * | ptr, |
|
|
size_t | size ) |
|
static |
Definition at line 116 of file template.h.
116 {
120}
static void * realloc(SELF *self, void *ptr, size_t size)
◆ TRAIT_ALLOC()
◆ unleak_and_delete()
| void unleak_and_delete |
( |
SELF * | self | ) |
|
|
static |