mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-21 12:29:43 -10:00
Serves one block size out of chunks taken from malloc() in bulk, with released blocks going on an intrusive free list. A caller that builds and tears down N same-sized objects pays a logarithmic number of calls into libc instead of N, and a rebuild of the same size touches libc not at all. Blocks keep their address while held, so a container that relocates the pointer -- qsort() in file_list_sort_on_alt(), memmove() in file_list_insert() -- moves the pointer and never the block. Covered by test/memory/test_mempool.c: block distinctness under a whole-block write, alignment for an unaligned block size, free-list reuse, a rebuild taking no new chunk, deinit with blocks outstanding, and interleaved churn across chunk boundaries. ASan+UBSan+LSan and TSan both clean, 10/10.