aligned_alloc is a C11/GNU libc surface, not a C++17-only API.
| 2541 | #if defined(__FASTGRIND_HAS_ALIGNED_ALLOC_WRAP) |
| 2542 | // aligned_alloc is a C11/GNU libc surface, not a C++17-only API. |
| 2543 | MEM_NO_INSTRUMENT MEM_INLINE_USED inline void *__wrap_aligned_alloc(size_t alignment, size_t size) |
| 2544 | { |
| 2545 | if (alignment == 0 || (alignment & (alignment - 1)) || (alignment % sizeof(void *) != 0)) |
| 2546 | { |
| 2547 | errno = EINVAL; |
| 2548 | return nullptr; |
| 2549 | } |
| 2550 | if (size % alignment != 0) |
| 2551 | { |
| 2552 | errno = EINVAL; |
| 2553 | return nullptr; |
| 2554 | } |
| 2555 | |
| 2556 | if (__mem_in_probe_) |
| 2557 | { |
| 2558 | #if defined(FASTGRIND_TC_MALLOC) |
| 2559 | return tc_memalign(alignment, size); |
| 2560 | #elif defined(FASTGRIND_JE_MALLOC) |
| 2561 | return je_aligned_alloc_emulate(alignment, size); |
| 2562 | #else |
| 2563 | return __real_aligned_alloc(alignment, size); |
| 2564 | #endif |
| 2565 | } |
| 2566 | |
| 2567 | __mem_in_probe_ = true; |
| 2568 | |
| 2569 | void *p = nullptr; |
| 2570 | #if defined(FASTGRIND_TC_MALLOC) |
| 2571 | p = tc_memalign(alignment, size); |
| 2572 | #elif defined(FASTGRIND_JE_MALLOC) |
| 2573 | p = je_aligned_alloc_emulate(alignment, size); |
| 2574 | #else |
| 2575 | p = __real_aligned_alloc(alignment, size); |
| 2576 | #endif |
| 2577 | |
| 2578 | if (p) |
| 2579 | memLocalInfo::instance().add(malloc_usable_size(p)); |
| 2580 | |
| 2581 | __mem_in_probe_ = false; |
| 2582 | return p; |
| 2583 | } |
| 2584 | |
| 2585 | #endif |
| 2586 |
nothing calls this directly
no test coverage detected