aboutsummaryrefslogtreecommitdiff
path: root/common/xmlparser.h
diff options
context:
space:
mode:
authorVicent Marti2008-10-05 10:19:09 +0000
committerVicent Marti2008-10-05 10:19:09 +0000
commite32fc0ccca2570fc560969507351cf99a304ebf4 (patch)
treeccdc9d089daa997aab74d28591118ecb0231f5e2 /common/xmlparser.h
parent1380e4f7e70e712ad7984c5b5e8b070ab954987c (diff)
downloadscummvm-rg350-e32fc0ccca2570fc560969507351cf99a304ebf4.tar.gz
scummvm-rg350-e32fc0ccca2570fc560969507351cf99a304ebf4.tar.bz2
scummvm-rg350-e32fc0ccca2570fc560969507351cf99a304ebf4.zip
Added a fixed memory pool for XML Node allocation, as suggested by Max.
svn-id: r34747
Diffstat (limited to 'common/xmlparser.h')
-rw-r--r--common/xmlparser.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/common/xmlparser.h b/common/xmlparser.h
index 4b76278d47..ad9ad799f0 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -47,6 +47,8 @@ namespace Common {
External documentation available at:
http://www.smartlikearoboc.com/scummvm_doc/xmlparser_doc.html
*/
+
+#define MAX_XML_DEPTH 8
#define XML_KEY(keyName) {\
lay = new CustomXMLKeyLayout;\
@@ -112,7 +114,7 @@ public:
virtual ~XMLParser() {
while (!_activeKey.empty())
- delete _activeKey.pop();
+ freeNode(_activeKey.pop());
delete _XMLkeys;
delete _stream;
@@ -166,6 +168,18 @@ public:
int depth;
XMLKeyLayout *layout;
};
+
+ FixedSizeMemoryPool<sizeof(ParserNode), MAX_XML_DEPTH> _nodePool;
+
+ ParserNode *allocNode() {
+ void* mem = _nodePool.malloc();
+ return new (mem) ParserNode;
+ }
+
+ void freeNode(ParserNode *node) {
+ node->~ParserNode();
+ _nodePool.free(node);
+ }
/**
* Loads a file into the parser.