Allocate a buffer of memory with the given size and alignment.

Synopsis

Declared in <llvm/Support/MemAlloc.h>

void*
allocate_buffer(
    size_t Size,
    size_t Alignment);

Description

When the compiler supports aligned operator new, this will use it to handle even over‐aligned allocations.

However, this doesn't make any attempt to leverage the fancier techniques like posix_memalign due to portability. It is mostly intended to allow compatibility with platforms that, after aligned allocation was added, use reduced default alignment.

Return Value

A non‐null pointer to the allocated memory.

Parameters

Name

Description

Size

Number of bytes to allocate.

Alignment

Required alignment of the allocated memory in bytes.

Created with MrDocs