Released the memory allocated in the memory pool when backtracking from Parser::parseTemplateId().

This commit is contained in:
Roberto Raggi
2009-10-22 16:46:26 +02:00
parent 8175e4e4c6
commit 2a7fa04101
4 changed files with 64 additions and 0 deletions

View File

@@ -110,6 +110,19 @@ void *MemoryPool::allocate_helper(size_t size)
return addr;
}
MemoryPool::State MemoryPool::state() const
{ return State(ptr, _blockCount); }
void MemoryPool::rewind(const State &state)
{
if (_blockCount == state.blockCount && state.ptr < ptr) {
if (_initializeAllocatedMemory)
memset(state.ptr, '\0', ptr - state.ptr);
ptr = state.ptr;
}
}
Managed::Managed()
{ }