Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
emscripten-core
GitHub Repository: emscripten-core/emscripten
Path: blob/main/system/lib/libc/compat/aligned_alloc.c
6175 views
1
#include <stdlib.h>
2
3
// Musl has an aligned_alloc routine, but that builds on top of standard malloc(). We are using dlmalloc, so
4
// we can route to its implementation instead.
5
void * weak aligned_alloc(size_t alignment, size_t size)
6
{
7
void *ptr;
8
if ((alignment % sizeof(void *) != 0) || (size % alignment) != 0)
9
return 0;
10
int ret = posix_memalign(&ptr, alignment, size);
11
return (ret == 0) ? ptr : 0;
12
}
13
14