I'm building a portable arena allocator for embedded systems.
Like for malloc
, one of the requirements is to return a pointer aligned with the memory.
The question is: Is there a way to know at compile time what are the memory alignment requirements for a given platform in C?
I've seen this code snippets floating around, but I haven't find any documentation to support it's validity:
#ifndef DEFAULT_ALIGNMENT
#define DEFAULT_ALIGNMENT (2*sizeof(void *))
#endif