Memory: Mak full explicit destructor functionality, techincally correctly.
Completes a TODO from previous commit.
This commit is contained in:
		
							parent
							
								
									1cf2b35529
								
							
						
					
					
						commit
						698bf7547a
					
				@ -202,14 +202,17 @@ void TPoolAllocator::pop()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    while (inUseList != page) {
 | 
					    while (inUseList != page) {
 | 
				
			||||||
        tHeader* nextInUse = inUseList->nextPage;
 | 
					        tHeader* nextInUse = inUseList->nextPage;
 | 
				
			||||||
        if (inUseList->pageCount > 1) {
 | 
					        size_t pageCount = inUseList->pageCount;
 | 
				
			||||||
            inUseList->~tHeader(); // currently, just a debug allocation checker
 | 
					
 | 
				
			||||||
 | 
					        // 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<char*>(inUseList);
 | 
					            delete [] reinterpret_cast<char*>(inUseList);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            inUseList->nextPage = freeList;
 | 
					            inUseList->nextPage = freeList;
 | 
				
			||||||
            freeList = inUseList;
 | 
					            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;
 | 
					        inUseList = nextInUse;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user