Bound individual size of allocation to put in free list
All checks were successful
Tests / Release [gcc] total: 827, passed: 827
GNU C Compiler (gcc) |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |0|0|0|0|:clap:
Tests / Release [gcc,aarch64] total: 826, passed: 826
Tests / Coverage total: 825, passed: 825
weaselab/conflict-set/pipeline/head This commit looks good

This commit is contained in:
2024-03-08 22:41:18 -08:00
parent e32bea7b29
commit 44a023c2f4

View File

@@ -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 <class T, int64_t kMemoryBound = (1 << 20)>
template <class T, int64_t kMemoryBound = (1 << 20),
int64_t kMaxIndividual = (1 << 10)>
struct BoundedFreeListAllocator {
static_assert(sizeof(T) >= sizeof(void *));
static_assert(std::derived_from<T, Node>);
@@ -296,7 +297,8 @@ struct BoundedFreeListAllocator {
--liveAllocations;
#endif
static_assert(std::is_trivially_destructible_v<T>);
if (freeListBytes >= kMemoryBound) {
if (sizeof(T) + p->partialKeyCapacity > kMaxIndividual ||
freeListBytes >= kMemoryBound) {
return free(p);
}
memcpy((void *)p, &freeList, sizeof(freeList));