From 859fc08886eeb6d2561ef45bd0e21c222e24d3db Mon Sep 17 00:00:00 2001 From: Roger Hughston Date: Fri, 12 May 2006 23:48:02 +0000 Subject: [PATCH] small memory leak with multiple #defines... --- dtool/src/cppparser/cppPreprocessor.cxx | 12 ++++++++++++ dtool/src/cppparser/cppType.cxx | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/dtool/src/cppparser/cppPreprocessor.cxx b/dtool/src/cppparser/cppPreprocessor.cxx index 7877ecd850..5c2dfffb6d 100644 --- a/dtool/src/cppparser/cppPreprocessor.cxx +++ b/dtool/src/cppparser/cppPreprocessor.cxx @@ -1231,7 +1231,19 @@ handle_define_directive(const string &args, int first_line, manifest->_expr = parse_expr(expr_string, global_scope, global_scope); } } + + // ok one memory leak here.. + Manifests::iterator mi = _manifests.find(manifest->_name); + if(mi != _manifests.end()) + { + // i do not see a goodway to compare the old and new hmmmm + //cerr << "Warning Overwriting Constant " << manifest->_name << "\n"; + delete mi->second; + } + _manifests[manifest->_name] = manifest; + + } } diff --git a/dtool/src/cppparser/cppType.cxx b/dtool/src/cppparser/cppType.cxx index 756afd8ba7..6faf33f861 100644 --- a/dtool/src/cppparser/cppType.cxx +++ b/dtool/src/cppparser/cppType.cxx @@ -265,7 +265,7 @@ new_type(CPPType *type) { // however, it's not. Thus, someone failed to call new_type() on // a type pointer before saving it somewhere. Fix me soon. **** - //delete type; + delete type; } return *result.first; }