mirror of
https://github.com/mborgerding/kissfft.git
synced 2026-11-18 20:09:30 -05:00
kiss_fftnd_alloc and kiss_fftndr_alloc carve several objects out of one allocation, advancing by KISS_FFT_ALIGN_SIZE_UP(size), which is the identity outside SIMD builds. So objects started at whatever offset the previous one ended: - kiss_fftnd: after an odd number of int dims, tmpbuf and the per-dimension kiss_fft_state objects were 4 bytes off, misaligned for double. - kiss_fftndr: the nd state (which holds pointers) followed the real-FFT state, whose size is only a multiple of 4 for int16_t. These are misaligned accesses (undefined behavior; SIGBUS on strict platforms, silent on x86). Add KISS_FFT_PACK_SIZE_UP to _kiss_fft_guts.h, which rounds a size up to a multiple of the size of a union of pointer, int and kiss_fft_cpx (a multiple of each of their alignments, and of the SIMD vector alignment), and use it for every object in both layouts. The reported sizes grow by a few bytes of padding. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ME1hnNaoD3ZcMj9H8TSYkZ