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

via libc-commits libc-commits at lists.llvm.org
Thu Oct 10 10:41:15 PDT 2024


================
@@ -214,15 +193,14 @@ void *FreeListHeap<NUM_BUCKETS>::realloc(void *ptr, size_t size) {
   return new_ptr;
 }
 
-template <size_t NUM_BUCKETS>
-void *FreeListHeap<NUM_BUCKETS>::calloc(size_t num, size_t size) {
+LIBC_INLINE void *FreeListHeap::calloc(size_t num, size_t size) {
   void *ptr = allocate(num * size);
   if (ptr != nullptr)
     LIBC_NAMESPACE::inline_memset(ptr, 0, num * size);
----------------
nopsledder wrote:

I'me not at all sure here, but would something like `std::fill` that could operate on words instead of bytes be faster here?

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


More information about the libc-commits mailing list