diff --git a/ConflictSet.cpp b/ConflictSet.cpp index a467365..d9f1889 100644 --- a/ConflictSet.cpp +++ b/ConflictSet.cpp @@ -174,18 +174,16 @@ struct Node { Node *parent = nullptr; Entry entry; int32_t partialKeyLen = 0; - int16_t numChildren : 15 = 0; - bool entryPresent : 1 = false; + int16_t numChildren = 0; + bool entryPresent = false; uint8_t parentsIndex = 0; /* end section that's copied to the next node */ Type type; -#ifndef NDEBUG - // Leaving this uninitialized is intentional and necessary to expect asserts - // to pass. Basically it needs to be preserved when going to the free list and - // back. + + // Leaving this uninitialized is intentional and necessary for correctness. + // Basically it needs to be preserved when going to the free list and back. int32_t partialKeyCapacity; -#endif uint8_t *partialKey(); }; @@ -274,24 +272,19 @@ struct BoundedFreeListAllocator { #endif if (freeList != nullptr) { T *n = (T *)freeList; - VALGRIND_MAKE_MEM_DEFINED(n, sizeof(T)); - if (n->partialKeyLen >= partialKeyCapacity) { + VALGRIND_MAKE_MEM_UNDEFINED(n, sizeof(T)); + VALGRIND_MAKE_MEM_DEFINED(&n->partialKeyCapacity, + sizeof(n->partialKeyCapacity)); + if (n->partialKeyCapacity >= partialKeyCapacity) { memcpy(&freeList, freeList, sizeof(freeList)); --freeListSize; - VALGRIND_MAKE_MEM_UNDEFINED(n, sizeof(T)); -#ifndef NDEBUG - VALGRIND_MAKE_MEM_DEFINED(&n->partialKeyCapacity, - sizeof(n->partialKeyCapacity)); -#endif return new (n) T; } VALGRIND_MAKE_MEM_NOACCESS(n, sizeof(T)); } auto *result = new (safe_malloc(sizeof(T) + partialKeyCapacity)) T; -#ifndef NDEBUG result->partialKeyCapacity = partialKeyCapacity; -#endif return result; }