Skip to content
HeapAllocatorInitAligned

HeapAllocatorInitAligned

Description

Initialize a HeapAllocator with a custom alignment floor. Over-page-aligned requests bypass the bin path and go straight to the embedded PageAllocator.

Usage example (Cross-references)

Usage examples (Cross-references)
    
    static bool test_overaligned_alloc(void) {
        HeapAllocator heap  = HeapAllocatorInitAligned(64);
        Allocator    *alloc = ALLOCATOR_OF(&heap);
        WriteFmt("Testing VecInit with aligned allocator\n");
    
        HeapAllocator aligned4  = HeapAllocatorInitAligned(4);
        HeapAllocator aligned16 = HeapAllocatorInitAligned(16);
    
        HeapAllocator aligned4  = HeapAllocatorInitAligned(4);
        HeapAllocator aligned16 = HeapAllocatorInitAligned(16);
    
        // Test with int type and 4-byte alignment
        WriteFmt("Testing VecInit with aligned allocator and deep copy\n");
    
        HeapAllocator aligned8 = HeapAllocatorInitAligned(8);
    
        // Test with struct type, custom copy/deinit functions, and 8-byte alignment
        // allocator's settings.
        HeapAllocator h_default = HeapAllocatorInit();
        HeapAllocator h8        = HeapAllocatorInitAligned(8);
        HeapAllocator h16       = HeapAllocatorInitAligned(16);
        HeapAllocator h32       = HeapAllocatorInitAligned(32);
        HeapAllocator h_default = HeapAllocatorInit();
        HeapAllocator h8        = HeapAllocatorInitAligned(8);
        HeapAllocator h16       = HeapAllocatorInitAligned(16);
        HeapAllocator h32       = HeapAllocatorInitAligned(32);
        HeapAllocator h64       = HeapAllocatorInitAligned(64);
        HeapAllocator h8        = HeapAllocatorInitAligned(8);
        HeapAllocator h16       = HeapAllocatorInitAligned(16);
        HeapAllocator h32       = HeapAllocatorInitAligned(32);
        HeapAllocator h64       = HeapAllocatorInitAligned(64);
        HeapAllocator h16       = HeapAllocatorInitAligned(16);
        HeapAllocator h32       = HeapAllocatorInitAligned(32);
        HeapAllocator h64       = HeapAllocatorInitAligned(64);
    
        h_default.base.retry_limit = 17;
    
        DefaultAllocator alloc      = DefaultAllocatorInit();
        HeapAllocator    aligned8   = HeapAllocatorInitAligned(8);
    
        // Create a vector of integers
    
        DefaultAllocator alloc    = DefaultAllocatorInit();
        HeapAllocator    aligned8 = HeapAllocatorInitAligned(8);
    
        // Create a vector of integers with default alignment (1)
        alloc.base.retry_limit = 31;
    
        HeapAllocator aligned_8 = HeapAllocatorInitAligned(8);
        aligned_8.base.retry_limit = 31;
        HeapAllocator aligned_16 = HeapAllocatorInitAligned(16);
        HeapAllocator aligned_8 = HeapAllocatorInitAligned(8);
        aligned_8.base.retry_limit = 31;
        HeapAllocator aligned_16 = HeapAllocatorInitAligned(16);
        aligned_16.base.retry_limit = 31;
        HeapAllocator aligned_32 = HeapAllocatorInitAligned(32);
        HeapAllocator aligned_16 = HeapAllocatorInitAligned(16);
        aligned_16.base.retry_limit = 31;
        HeapAllocator aligned_32 = HeapAllocatorInitAligned(32);
        aligned_32.base.retry_limit = 31;
        HeapAllocator aligned_64 = HeapAllocatorInitAligned(64);
        HeapAllocator aligned_32 = HeapAllocatorInitAligned(32);
        aligned_32.base.retry_limit = 31;
        HeapAllocator aligned_64 = HeapAllocatorInitAligned(64);
        aligned_64.base.retry_limit = 31;
        WriteFmt("Testing Graph aligned init and node id layout\n");
    
        HeapAllocator alloc = HeapAllocatorInitAligned(32);
    
        typedef Graph(int) IntGraph;
Last updated on