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 / SysAbort.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    void ValidateAllocator(const Allocator *self) {
        if (!self) {
            LOG_FATAL("NULL allocator pointer");
    
    void *AllocatorAlloc(Allocator *self, size bytes, i8 zeroed) {
        ValidateAllocator(self);
    
        size  attempts = allocator_attempt_limit(self);
    
    void *AllocatorRealloc(Allocator *self, void *ptr, size old_size, size new_size) {
        ValidateAllocator(self);
    
        size  attempts = allocator_attempt_limit(self);
            return;
        }
        ValidateAllocator(self);
        self->deallocate(self, ptr, bytes);
    }
Last updated on