Fix memory leak of RSExport* object create in processExport(). Now, they will
properly be freed after their associated RSContext was destroyed.
diff --git a/slang_rs_context.h b/slang_rs_context.h
index 7e95d56..19f81ef 100644
--- a/slang_rs_context.h
+++ b/slang_rs_context.h
@@ -11,8 +11,6 @@
#include "clang/Lex/Preprocessor.h"
-#include "slang_rs_export_element.h"
-
namespace llvm {
class LLVMContext;
class TargetData;
@@ -27,10 +25,10 @@
} // namespace clang
namespace slang {
-
-class RSExportVar;
-class RSExportFunc;
-class RSExportType;
+ class RSExportable;
+ class RSExportVar;
+ class RSExportFunc;
+ class RSExportType;
class RSContext {
typedef llvm::StringSet<> NeedExportVarSet;
@@ -38,6 +36,7 @@
typedef llvm::StringSet<> NeedExportTypeSet;
public:
+ typedef std::list<RSExportable*> ExportableList;
typedef std::list<RSExportVar*> ExportVarList;
typedef std::list<RSExportFunc*> ExportFuncList;
typedef llvm::StringMap<RSExportType*> ExportTypeMap;
@@ -50,6 +49,8 @@
llvm::TargetData *mTargetData;
llvm::LLVMContext &mLLVMContext;
+ ExportableList mExportables;
+
// Record the variables/types/elements annotated in #pragma to be exported
NeedExportVarSet mNeedExportVars;
NeedExportFuncSet mNeedExportFuncs;
@@ -119,6 +120,10 @@
}
void processExport();
+ inline void newExportable(RSExportable *E) {
+ if (E != NULL)
+ mExportables.push_back(E);
+ }
typedef ExportVarList::const_iterator const_export_var_iterator;
const_export_var_iterator export_vars_begin() const {