MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / aligned_alloc

Function aligned_alloc

system/lib/libc/compat/aligned_alloc.c:5–12  ·  view source on GitHub ↗

Musl has an aligned_alloc routine, but that builds on top of standard malloc(). We are using dlmalloc, so we can route to its implementation instead.

Source from the content-addressed store, hash-verified

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.
5void * 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}

Callers 4

__libcpp_aligned_allocFunction · 0.50
aligned_allocMethod · 0.50
operator newFunction · 0.50
operator new[]Function · 0.50

Calls 1

posix_memalignFunction · 0.85

Tested by

no test coverage detected