[libc-commits] [libc] [libc] Use best-fit binary trie to make malloc logarithmic (PR #106259)

Michael Jones via libc-commits libc-commits at lists.llvm.org
Wed Nov 13 16:50:52 PST 2024


================
@@ -28,23 +28,16 @@ extern "C" cpp::byte __llvm_libc_heap_limit;
 using cpp::optional;
 using cpp::span;
 
-inline constexpr bool IsPow2(size_t x) { return x && (x & (x - 1)) == 0; }
+LIBC_INLINE constexpr bool IsPow2(size_t x) { return x && (x & (x - 1)) == 0; }
 
-static constexpr cpp::array<size_t, 6> DEFAULT_BUCKETS{16,  32,  64,
-                                                       128, 256, 512};
-
-template <size_t NUM_BUCKETS = DEFAULT_BUCKETS.size()> class FreeListHeap {
+class FreeListHeap {
----------------
michaelrj-google wrote:

I like `FreelistHeapAlloc` or similar to make it clear this is an allocator. "Heap" is what we call the memory we allocate outside of the stack, but it's also the name of a generic data structure.

https://github.com/llvm/llvm-project/pull/106259


More information about the libc-commits mailing list