Fix a few memory leaks
This commit is contained in:
@@ -55,7 +55,8 @@ public:
|
||||
}
|
||||
|
||||
~TemplatedApp() {
|
||||
|
||||
/* Let's just put everything here */
|
||||
httpContext->free();
|
||||
}
|
||||
|
||||
TemplatedApp(const TemplatedApp &other) {
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -111,6 +111,7 @@ struct DeflationStream {
|
||||
|
||||
~DeflationStream() {
|
||||
std::cout << "Destructing DeflationStream" << std::endl;
|
||||
deflateEnd(&deflationStream);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user