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
+2 -1
View File
@@ -55,7 +55,8 @@ public:
}
~TemplatedApp() {
/* Let's just put everything here */
httpContext->free();
}
TemplatedApp(const TemplatedApp &other) {
+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 */
+1
View File
@@ -111,6 +111,7 @@ struct DeflationStream {
~DeflationStream() {
std::cout << "Destructing DeflationStream" << std::endl;
deflateEnd(&deflationStream);
}
};