ValidateAllocator
Description
Validate an allocator base. Aborts via LOG_FATAL when the allocator is structurally invalid (NULL pointer, missing fn pointers, alignment is zero or not a power of two).
Parameters
| Name | Direction | Description |
|---|---|---|
self |
in | Allocator base to validate. |
Success
Function returns. The allocator is structurally valid.
Failure
Does not return - aborts via LOG_FATAL / Abort.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Allocator.c:41:
}
void ValidateAllocator(const Allocator *self) {
if (!self) {
LOG_FATAL("NULL allocator pointer");- In
Allocator.c:57:
void *AllocatorAlloc_dyn(Allocator *self, size bytes, i8 zeroed) {
ValidateAllocator(self);
size attempts = allocator_attempt_limit(self);- In
Allocator.c:71:
i8 AllocatorResize_dyn(Allocator *self, void *ptr, size new_size) {
ValidateAllocator(self);
// Resize requires a real allocation and a real new size. Anything
// degenerate falls outside the in-place contract (caller should
- In
Allocator.c:83:
void *AllocatorRemap_dyn(Allocator *self, void *ptr, size new_size) {
ValidateAllocator(self);
size attempts = allocator_attempt_limit(self);- In
Allocator.c:100:
return;
}
ValidateAllocator(self);
(void)self->deallocate(self, ptr);
}- In
Allocator.c:106:
#if FEATURE_ALLOC_STATS
void AllocatorResetStats(Allocator *self) {
ValidateAllocator(self);
u64 in_use = self->stats.bytes_in_use;
self->stats = (AllocatorStats) {0};- In
Map.Insert.c:333:
f.base.effort = ALLOCATOR_EFFORT_ONCE;
f.base.retry_limit = 0;
f.base.__magic = 0x1u; // ValidateAllocator only requires non-zero
f.inner = inner;
f.fail_now = false;
Last updated on