summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus/MemoryPool.cpp
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2009-10-22 16:46:26 +0200
committerRoberto Raggi <roberto.raggi@nokia.com>2009-10-22 16:48:06 +0200
commit2a7fa04101bf487f4fd6dd04297573f62157d41a (patch)
tree3707690d1ca2ec3fbde9cfd1be0d1964e9fa91a3 /src/shared/cplusplus/MemoryPool.cpp
parent8175e4e4c62bb5a587329ca5bb5c4c35508370d4 (diff)
downloadqt-creator-2a7fa04101bf487f4fd6dd04297573f62157d41a.tar.gz
Released the memory allocated in the memory pool when backtracking from Parser::parseTemplateId().
Diffstat (limited to 'src/shared/cplusplus/MemoryPool.cpp')
-rw-r--r--src/shared/cplusplus/MemoryPool.cpp13
1 files changed, 13 insertions, 0 deletions
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()
{ }