[libc-commits] [libc] [libc] Use best-fit binary trie to make malloc logarithmic (PR #106259)
Daniel Thornburgh via libc-commits
libc-commits at lists.llvm.org
Thu Oct 10 16:03:40 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);
----------------
mysterymath wrote:
This should use libc's optimized memset implementation, so it should work a word at a time whenever appropriate, or even using vector instructions when available.
https://github.com/llvm/llvm-project/pull/106259
More information about the libc-commits
mailing list