Browse Source

BUG: reduce the number of file handles kept open

Ken Martin 19 years ago
parent
commit
8ace577a2a
2 changed files with 12 additions and 15 deletions
  1. 12 13
      Source/cmMakefileTargetGenerator.cxx
  2. 0 2
      Source/cmMakefileTargetGenerator.h

+ 12 - 13
Source/cmMakefileTargetGenerator.cxx

@@ -33,7 +33,6 @@
 cmMakefileTargetGenerator::cmMakefileTargetGenerator()
 {
   this->BuildFileStream = 0;
-  this->ProgressFileStream = 0;
   this->InfoFileStream = 0;
   this->FlagFileStream = 0;
 }
@@ -92,13 +91,6 @@ void cmMakefileTargetGenerator::CreateRuleFile()
   this->ProgressFileNameFull = this->TargetBuildDirectoryFull;
   this->ProgressFileNameFull += "/progress.make";
 
-  this->ProgressFileStream = 
-    new cmGeneratedFileStream(this->ProgressFileNameFull.c_str());
-  if(!this->ProgressFileStream)
-    {
-    return;
-    }
-
   // reset the progress count
   this->NumberOfProgressActions = 0;
 
@@ -1055,29 +1047,36 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
 void cmMakefileTargetGenerator::WriteProgressVariables(unsigned long total,
                                                        unsigned long &current)
 {
+  cmGeneratedFileStream *progressFileStream = 
+    new cmGeneratedFileStream(this->ProgressFileNameFull.c_str());
+  if(!progressFileStream)
+    {
+    return;
+    }
+
   unsigned long num;
   unsigned long i;
   for (i = 1; i <= this->NumberOfProgressActions; ++i)
     {
-    *this->ProgressFileStream
+    *progressFileStream
       << "CMAKE_PROGRESS_" << i << " = ";
     if (total <= 100)
       {
       num = i + current;
-      *this->ProgressFileStream << num;
+      *progressFileStream << num;
       this->LocalGenerator->ProgressFiles[this->Target->GetName()]
         .push_back(num);
       }
     else if (((i+current)*100)/total > ((i-1+current)*100)/total)
       {
       num = ((i+current)*100)/total;
-      *this->ProgressFileStream << num;
+      *progressFileStream << num;
       this->LocalGenerator->ProgressFiles[this->Target->GetName()]
         .push_back(num);
       }
-    *this->ProgressFileStream << "\n";
+    *progressFileStream << "\n";
     }
   current += this->NumberOfProgressActions;
-  delete this->ProgressFileStream;
+  delete progressFileStream;
 }
 

+ 0 - 2
Source/cmMakefileTargetGenerator.h

@@ -129,8 +129,6 @@ protected:
   // the full path to the progress file
   std::string ProgressFileName;
   std::string ProgressFileNameFull;
-  // the stream for the build file
-  cmGeneratedFileStream *ProgressFileStream;
   unsigned long NumberOfProgressActions;
 
   // the path to the directory the build file is in