Skip to content

Commit 5551f94

Browse files
Unregister filters before clean the memory
1 parent d4981f0 commit 5551f94

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

generate/templates/manual/include/cleanup_handle.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
#include <memory>
66
#include <string>
77

8+
extern "C" {
9+
#include <git2.h>
10+
#include <git2/sys/filter.h>
11+
}
12+
13+
814
namespace nodegit {
915
class CleanupHandle {
1016
public:
@@ -14,6 +20,12 @@ namespace nodegit {
1420

1521
class FilterRegistryCleanupHandles : public CleanupHandle {
1622
public:
23+
~FilterRegistryCleanupHandles() {
24+
for(std::map<std::string, std::shared_ptr<CleanupHandle>>::iterator iter = registeredFilters.begin(); iter != registeredFilters.end(); ++iter) {
25+
std::string filtername = iter->first;
26+
git_filter_unregister(filtername.c_str());
27+
}
28+
}
1729
std::map<std::string, std::shared_ptr<CleanupHandle>> registeredFilters;
1830
};
1931
}

0 commit comments

Comments
 (0)