From 2a7fa04101bf487f4fd6dd04297573f62157d41a Mon Sep 17 00:00:00 2001 From: Roberto Raggi Date: Thu, 22 Oct 2009 16:46:26 +0200 Subject: Released the memory allocated in the memory pool when backtracking from Parser::parseTemplateId(). --- src/shared/cplusplus/MemoryPool.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/shared/cplusplus/MemoryPool.cpp') diff --git a/src/shared/cplusplus/MemoryPool.cpp b/src/shared/cplusplus/MemoryPool.cpp index 2002a65435..1453c62cd6 100644 --- a/src/shared/cplusplus/MemoryPool.cpp +++ b/src/shared/cplusplus/MemoryPool.cpp @@ -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() { } -- cgit v1.2.1