Function allocate

Summary

#include <include/EASTL/allocator_malloc.h>

(1) void * allocate(size_t n, int=0)

(2) void * allocate(size_t n, size_t alignment, size_t alignmentOffset, int=0)

Function overload

Synopsis

#include <include/EASTL/allocator_malloc.h>

void * allocate(size_t n, int=0)

Description

No description yet.

Source

Lines 91-92 in include/EASTL/allocator_malloc.h.

void* allocate(size_t n, int /*flags*/ = 0)
    { return malloc(n); }

Synopsis

#include <include/EASTL/allocator_malloc.h>

void * allocate(size_t n, size_t alignment, size_t alignmentOffset, int=0)

Description

No description yet.

Source

Lines 94-104 in include/EASTL/allocator_malloc.h.

void* allocate(size_t n, size_t alignment, size_t alignmentOffset, int /*flags*/ = 0)
{ 
    #if EASTL_ALIGNED_MALLOC_AVAILABLE
        if((alignmentOffset % alignment) == 0) // We check for (offset % alignmnent == 0) instead of (offset == 0) because any block which is aligned on e.g. 64 also is aligned at an offset of 64 by definition. 
            return memalign(alignment, n); // memalign is more consistently available than posix_memalign.
    #else
        if((alignment <= EASTL_SYSTEM_ALLOCATOR_MIN_ALIGNMENT) && ((alignmentOffset % alignment) == 0))
            return malloc(n);
    #endif
    return NULL;
}





Add Discussion as Guest

Log in