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.
| 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 | } |
no test coverage detected