From 390cff7a1a09778c2565076f02cb9e7660b96179 Mon Sep 17 00:00:00 2001 From: Ziliang Guo Date: Mon, 21 Apr 2008 02:15:19 +0000 Subject: [PATCH] =?UTF-8?q?Fix=20memory=20leaks,=20patch=20by=20Samuel=20S?= =?UTF-8?q?erapi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=33082 --- reactos/tools/rbuild/define.cpp | 4 ++++ reactos/tools/rbuild/directory.cpp | 7 +++++++ reactos/tools/rbuild/module.cpp | 7 ++++++- reactos/tools/rbuild/project.cpp | 13 +++++++------ reactos/tools/rbuild/rbuild.h | 3 ++- 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/reactos/tools/rbuild/define.cpp b/reactos/tools/rbuild/define.cpp index d071a749ca7..d972d672b0c 100644 --- a/reactos/tools/rbuild/define.cpp +++ b/reactos/tools/rbuild/define.cpp @@ -57,6 +57,10 @@ Define::Define ( const Project& project, Define::~Define () { +// if ( node ) +// delete node; +// if ( module ) +// delete module; } void diff --git a/reactos/tools/rbuild/directory.cpp b/reactos/tools/rbuild/directory.cpp index 2a612fe7114..381328398f3 100644 --- a/reactos/tools/rbuild/directory.cpp +++ b/reactos/tools/rbuild/directory.cpp @@ -240,3 +240,10 @@ Directory::CreateRule ( FILE* f, i->second->CreateRule ( f, path ); } } + +Directory::~Directory() +{ + std::map::iterator theIterator; + for ( theIterator = subdirs.begin (); theIterator != subdirs.end (); theIterator++ ) + delete theIterator->second; +} diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 4af7adef2f7..d852224d245 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -494,7 +494,12 @@ Module::~Module () delete bootstrap; if ( importLibrary ) delete importLibrary; - delete output; + if ( dependency ) + delete dependency; + if ( autoRegister ) + delete autoRegister; + if ( output ) + delete output; } void diff --git a/reactos/tools/rbuild/project.cpp b/reactos/tools/rbuild/project.cpp index c25cc3e36ec..f60f828b142 100644 --- a/reactos/tools/rbuild/project.cpp +++ b/reactos/tools/rbuild/project.cpp @@ -195,7 +195,8 @@ Project::~Project () delete cdfiles[i]; for ( i = 0; i < installfiles.size (); i++ ) delete installfiles[i]; - delete head; + if ( head ) + delete head; } const Property* @@ -252,7 +253,7 @@ Project::ResolveProperties ( const string& s ) const void Project::SetConfigurationOption ( char* s, string name, - string* alternativeName ) + string alternativeName ) { const Property* property = LookupProperty ( name ); if ( property != NULL && property->value.length () > 0 ) @@ -268,11 +269,11 @@ Project::SetConfigurationOption ( char* s, "#define %s\n", property->name.c_str () ); } - else if ( alternativeName != NULL ) + else if ( !alternativeName.empty() ) { s = s + sprintf ( s, "#define %s\n", - alternativeName->c_str () ); + alternativeName.c_str () ); } } @@ -280,7 +281,7 @@ void Project::SetConfigurationOption ( char* s, string name ) { - SetConfigurationOption ( s, name, NULL ); + SetConfigurationOption ( s, name, "" ); } void @@ -301,7 +302,7 @@ Project::WriteConfigurationFile () SetConfigurationOption ( s, "ARCH" ); SetConfigurationOption ( s, "OPTIMIZED" ); - SetConfigurationOption ( s, "MP", new string ( "UP" ) ); + SetConfigurationOption ( s, "MP", "UP"); SetConfigurationOption ( s, "ACPI" ); SetConfigurationOption ( s, "_3GB" ); diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index 1e0f4313387..e9f7f205125 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -134,6 +134,7 @@ public: std::string name; directory_map subdirs; Directory ( const std::string& name ); + ~Directory(); void Add ( const char* subdir ); void GenerateTree ( DirectoryLocation root, bool verbose ); @@ -256,7 +257,7 @@ private: const Property* LookupProperty ( const std::string& name ) const; void SetConfigurationOption ( char* s, std::string name, - std::string* alternativeName ); + std::string alternativeName ); void SetConfigurationOption ( char* s, std::string name ); void ReadXml ();