Skip to content

HeapAllocator

Description

Create an allocator descriptor backed by the process heap. The returned allocator uses malloc/realloc/free semantics, with aligned allocation where required by the requested alignment.

Success

Returns a heap-backed allocator descriptor.

Failure

Function cannot fail.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    Allocator HeapAllocator(void) {
        return (Allocator) {
            .state       = NULL,
    
    Allocator AllocatorBind(Allocator alloc) {
        Allocator heap = HeapAllocator();
    
        if (!alloc.allocate) {
        WriteFmt("Testing BitVecClone allocator inheritance\n");
    
        Allocator alloc = HeapAllocator();
        alloc.effort = ALLOCATOR_EFFORT_RETRY_FALLBACK;
        alloc.retry_limit = 9;
        WriteFmt("Testing FloatClone allocator inheritance\n");
    
        Allocator alloc = HeapAllocator();
        alloc.effort = ALLOCATOR_EFFORT_RETRY_FALLBACK;
        alloc.retry_limit = 6;
        WriteFmt("Testing IntClone allocator inheritance\n");
    
        Allocator alloc = HeapAllocator();
        alloc.effort = ALLOCATOR_EFFORT_RETRY_FALLBACK;
        alloc.retry_limit = 5;
        WriteFmt("Testing Str clone allocator inheritance\n");
    
        Allocator alloc = HeapAllocator();
        alloc.effort = ALLOCATOR_EFFORT_RETRY_FALLBACK;
        alloc.retry_limit = 7;
        typedef Vec(int) IntVec;
    
        Allocator alloc = HeapAllocator();
        alloc.effort = ALLOCATOR_EFFORT_RETRY_FALLBACK;
        alloc.retry_limit = 11;
    /// TAGS: Allocator, Macro, Default, Memory
    ///
    #define DefaultAllocator() HeapAllocator()
    
    #endif // MISRA_STD_ALLOCATOR_H
Last updated on