summaryrefslogtreecommitdiff
path: root/src/parsers/generic.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-07 19:32:46 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-07 19:32:46 +0300
commit03b8a1e6cf21dbcd3f6f03311cf02b91f3630c26 (patch)
treecb23fbbb4f716b6653091cdc14023a6c2f49b913 /src/parsers/generic.cpp
parentdb6bbfe7d662460e5357f9d8fdbdd142cae3d8e1 (diff)
downloadparanucker-03b8a1e6cf21dbcd3f6f03311cf02b91f3630c26.tar.gz
paranucker-03b8a1e6cf21dbcd3f6f03311cf02b91f3630c26.tar.bz2
paranucker-03b8a1e6cf21dbcd3f6f03311cf02b91f3630c26.tar.xz
paranucker-03b8a1e6cf21dbcd3f6f03311cf02b91f3630c26.zip
Add memoryusage plugin command. It show only number of allocated nodes.
Diffstat (limited to 'src/parsers/generic.cpp')
-rw-r--r--src/parsers/generic.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parsers/generic.cpp b/src/parsers/generic.cpp
index ed00197..5f53843 100644
--- a/src/parsers/generic.cpp
+++ b/src/parsers/generic.cpp
@@ -19,12 +19,16 @@
#include "parsers/generic.h"
+#include "command.h"
+
#include "includes/nodeincludes.h"
#include "includes/parserincludes.h"
#include "includes/parserdefines.inc"
#include "localconsts.h"
+int allocations = 0;
+
namespace Generic
{
@@ -100,6 +104,8 @@ Node *createParseNode(Node *parent,
node->nodeType.c_str(),
tag.c_str());
}
+ if (!parent)
+ delete node;
return nullptr;
}
@@ -123,6 +129,15 @@ Node *parseNodes(tree gccNode)
return createParseNode(nullptr, gccNode, FUNCTION_DECL);
}
+void cleanAllNodes(Node *node)
+{
+ if (command == Command::MemoryUsage)
+ Log::error("Allocations before cleanup: %d", allocations);
+ cleanNodes(node);
+ if (command == Command::MemoryUsage)
+ Log::error("Allocations after cleanup: %d", allocations);
+}
+
void cleanNodes(Node *node)
{
FOR_EACH (std::vector<Node*>::iterator, it, node->childs)