From 89cdce36da297f66f7f8f687f617b4c85a099e55 Mon Sep 17 00:00:00 2001 From: eidheim Date: Fri, 1 Jul 2016 09:06:39 +0200 Subject: [PATCH] Fixes #26: fixed memory leak in clang::Index --- src/Index.cc | 7 +++++-- src/Index.h | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Index.cc b/src/Index.cc index 8208c7d..2077132 100644 --- a/src/Index.cc +++ b/src/Index.cc @@ -2,6 +2,9 @@ clang::Index:: Index(int excludeDeclarationsFromPCH, int displayDiagnostics) { - cx_index = clang_createIndex(excludeDeclarationsFromPCH, - displayDiagnostics); + cx_index = clang_createIndex(excludeDeclarationsFromPCH, displayDiagnostics); } + +clang::Index::~Index() { + clang_disposeIndex(cx_index); +} \ No newline at end of file diff --git a/src/Index.h b/src/Index.h index 5ac32d0..cd41977 100644 --- a/src/Index.h +++ b/src/Index.h @@ -6,6 +6,7 @@ namespace clang { class Index { public: Index(int excludeDeclarationsFromPCH, int displayDiagnostics); + ~Index(); CXIndex cx_index; }; } // namespace clang