Download upstream/emscripten/system/lib/libc/compat/aligned_alloc.c from arudradey/flst: direct link, hf CLI and curl.
- Browser
- Download file 415 Bytes
-
https://huggingface.co/arudradey/flst/resolve/main/upstream/emscripten/system/lib/libc/compat/aligned_alloc.c
- Command line
-
hf download hf://arudradey/flst/upstream/emscripten/system/lib/libc/compat/aligned_alloc.c
-
curl -L -o aligned_alloc.c https://huggingface.co/arudradey/flst/resolve/main/upstream/emscripten/system/lib/libc/compat/aligned_alloc.c
415 Bytes
| // 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. | |
| void * weak aligned_alloc(size_t alignment, size_t size) | |
| { | |
| void *ptr; | |
| if ((alignment % sizeof(void *) != 0) || (size % alignment) != 0) | |
| return 0; | |
| int ret = posix_memalign(&ptr, alignment, size); | |
| return (ret == 0) ? ptr : 0; | |
| } | |