Skip to content
ValidateAllocator

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)
    }
    
    void ValidateAllocator(const Allocator *self) {
        if (!self) {
            LOG_FATAL("NULL allocator pointer");
    
    void *AllocatorAlloc_dyn(Allocator *self, size bytes, i8 zeroed) {
        ValidateAllocator(self);
    
        size  attempts = allocator_attempt_limit(self);
    
    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
    
    void *AllocatorRemap_dyn(Allocator *self, void *ptr, size new_size) {
        ValidateAllocator(self);
    
        size  attempts = allocator_attempt_limit(self);
            return;
        }
        ValidateAllocator(self);
        (void)self->deallocate(self, ptr);
    }
    #if FEATURE_ALLOC_STATS
    void AllocatorResetStats(Allocator *self) {
        ValidateAllocator(self);
        u64 in_use  = self->stats.bytes_in_use;
        self->stats = (AllocatorStats) {0};
        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