From 698bf7547a96b6feb7291e8ddc0d5d16475dbae2 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Tue, 21 Nov 2017 14:32:39 -0700 Subject: [PATCH] Memory: Mak full explicit destructor functionality, techincally correctly. Completes a TODO from previous commit. --- glslang/MachineIndependent/PoolAlloc.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/glslang/MachineIndependent/PoolAlloc.cpp b/glslang/MachineIndependent/PoolAlloc.cpp index 7d07a399..84c40f4e 100644 --- a/glslang/MachineIndependent/PoolAlloc.cpp +++ b/glslang/MachineIndependent/PoolAlloc.cpp @@ -202,14 +202,17 @@ void TPoolAllocator::pop() while (inUseList != page) { tHeader* nextInUse = inUseList->nextPage; - if (inUseList->pageCount > 1) { - inUseList->~tHeader(); // currently, just a debug allocation checker + size_t pageCount = inUseList->pageCount; + + // This technically ends the lifetime of the header as C++ object, + // but we will still control the memory and reuse it. + inUseList->~tHeader(); // currently, just a debug allocation checker + + if (pageCount > 1) { delete [] reinterpret_cast(inUseList); } else { inUseList->nextPage = freeList; freeList = inUseList; - // inUseList->~tHeader(); TODO: this should probably call the allocation checker, but not the destructor - // ...if the destructor actually overwrites nextPage, that would effect freeList->nextPage } inUseList = nextInUse; }