Fix a few memory leaks

This commit is contained in:
Alex Hultman
2018-12-30 17:17:22 +01:00
parent 4407beedf7
commit 6618f7194b
4 changed files with 29 additions and 3 deletions
+10
View File
@@ -169,6 +169,15 @@ private:
}
}
void freeNode(Node *node) {
for (auto *p : node->children) {
freeNode(p);
}
if (node != &tree) {
delete node;
}
}
public:
HttpRouter() {
/* Make sure unhandled is at index 0 */
@@ -179,6 +188,7 @@ public:
~HttpRouter() {
// todo: delete all Nodes or use unique_ptr
freeNode(&tree);
}
/* For debugging you may want to print this */