ENH: Remove memory leak

This commit is contained in:
Andy Cedilnik 2004-05-05 10:13:19 -04:00
parent 22de04fab9
commit 23798f8a22
2 changed files with 13 additions and 5 deletions

View File

@ -21,6 +21,7 @@
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
#include <cmsys/Directory.hxx> #include <cmsys/Directory.hxx>
#include "cmGlob.h" #include "cmGlob.h"
#include "cmDynamicLoader.h"
#include "cmCTestSubmit.h" #include "cmCTestSubmit.h"
#include "curl/curl.h" #include "curl/curl.h"
@ -33,7 +34,8 @@
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include <float.h> #include <float.h>
#include "cmDynamicLoader.h"
#include <memory> // auto_ptr
#define SAFEDIV(x,y) (((y)!=0)?((x)/(y)):(0)) #define SAFEDIV(x,y) (((y)!=0)?((x)/(y)):(0))
#define DEBUGOUT std::cout << __LINE__ << " "; std::cout #define DEBUGOUT std::cout << __LINE__ << " "; std::cout
@ -3499,7 +3501,7 @@ int cmCTest::RunConfigurationScript(const std::string& total_script_arg)
gg.SetCMakeInstance(&cm); gg.SetCMakeInstance(&cm);
// read in the list file to fill the cache // read in the list file to fill the cache
cmLocalGenerator *lg = gg.CreateLocalGenerator(); std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
lg->SetGlobalGenerator(&gg); lg->SetGlobalGenerator(&gg);
// set a variable with the path to the current script // set a variable with the path to the current script
@ -4930,7 +4932,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir)
cmake cm; cmake cm;
cmGlobalGenerator gg; cmGlobalGenerator gg;
gg.SetCMakeInstance(&cm); gg.SetCMakeInstance(&cm);
cmLocalGenerator *lg = gg.CreateLocalGenerator(); std::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
lg->SetGlobalGenerator(&gg); lg->SetGlobalGenerator(&gg);
cmMakefile *mf = lg->GetMakefile(); cmMakefile *mf = lg->GetMakefile();

View File

@ -49,6 +49,7 @@
#endif #endif
#endif #endif
#include <memory> // auto_ptr
void cmNeedBackwardsCompatibility(const std::string& variable, void cmNeedBackwardsCompatibility(const std::string& variable,
int access_type, void* ) int access_type, void* )
@ -57,7 +58,12 @@ void cmNeedBackwardsCompatibility(const std::string& variable,
{ {
std::string message = "An attempt was made to access a variable: "; std::string message = "An attempt was made to access a variable: ";
message += variable; message += variable;
message += " that has not been defined. Some variables were always defined by CMake in versions prior to 1.6. To fix this you might need to set the cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If you are writing a CMakeList file, (or have already set CMAKE_BACKWARDS_COMPATABILITY to 1.4 or less) then you probably need to include a CMake module to test for the feature this variable defines."; message += " that has not been defined. Some variables were always defined "
"by CMake in versions prior to 1.6. To fix this you might need to set the "
"cache value of CMAKE_BACKWARDS_COMPATIBILITY to 1.4 or less. If you are "
"writing a CMakeList file, (or have already set "
"CMAKE_BACKWARDS_COMPATABILITY to 1.4 or less) then you probably need to "
"include a CMake module to test for the feature this variable defines.";
cmSystemTools::Error(message.c_str()); cmSystemTools::Error(message.c_str());
} }
} }
@ -248,7 +254,7 @@ void cmake::ReadListFile(const char *path)
// read in the list file to fill the cache // read in the list file to fill the cache
if(path) if(path)
{ {
cmLocalGenerator *lg = gg->CreateLocalGenerator(); std::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
lg->SetGlobalGenerator(gg); lg->SetGlobalGenerator(gg);
if (!lg->GetMakefile()->ReadListFile(0, path)) if (!lg->GetMakefile()->ReadListFile(0, path))
{ {