From 44a023c2f403203bd70a1998bbc4e01466198ceb Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Fri, 8 Mar 2024 22:41:18 -0800 Subject: [PATCH] Bound individual size of allocation to put in free list --- ConflictSet.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ConflictSet.cpp b/ConflictSet.cpp index 58b2b7d..ac83c01 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -260,7 +260,8 @@ static_assert(sizeof(Node4) < kMinChildrenNode4 * kBytesPerKey); // Bounds memory usage in free list, but does not account for memory for partial // keys. -template +template struct BoundedFreeListAllocator { static_assert(sizeof(T) >= sizeof(void *)); static_assert(std::derived_from); @@ -296,7 +297,8 @@ struct BoundedFreeListAllocator { --liveAllocations; #endif static_assert(std::is_trivially_destructible_v); - if (freeListBytes >= kMemoryBound) { + if (sizeof(T) + p->partialKeyCapacity > kMaxIndividual || + freeListBytes >= kMemoryBound) { return free(p); } memcpy((void *)p, &freeList, sizeof(freeList));