MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / aligned_alloc

Function aligned_alloc

src/framework/audio/detail/speech_fft_internal.h:176–183  ·  view source on GitHub ↗

Use posix_memalign on POSIX systems when explicitly enabled. The portable aligned_alloc below stores metadata at ptr[-1], which conflicts with ASAN's heap redzone and causes intermittent bus errors.

Source from the content-addressed store, hash-verified

174// The portable aligned_alloc below stores metadata at ptr[-1], which conflicts
175// with ASAN's heap redzone and causes intermittent bus errors.
176inline void *aligned_alloc(size_t align, size_t size)
177 {
178 align = std::max(align, sizeof(void*)); // posix_memalign requires align >= sizeof(void*)
179 void *ptr = nullptr;
180 if (posix_memalign(&ptr, align, size) != 0)
181 throw std::bad_alloc();
182 return ptr;
183 }
184inline void aligned_dealloc(void *ptr)
185 { free(ptr); }
186#else

Callers 4

rallocMethod · 0.85
allocateMethod · 0.85
rdma_probeMethod · 0.85
aligned_malloc_hostFunction · 0.85

Calls 1

maxFunction · 0.85

Tested by

no test coverage detected