summaryrefslogtreecommitdiffstats
path: root/Source/CPack/cmCPackLog.cxx
diff options
context:
space:
mode:
authorMarc Chevrier <marc.chevrier@gmail.com>2020-03-02 09:41:17 (GMT)
committerMarc Chevrier <marc.chevrier@gmail.com>2020-03-08 15:32:44 (GMT)
commit44867a8c013a2ae6b828ef12af8e81cb73795483 (patch)
treec81f902ed5de798ea88a6c4e5bd1f7d57c1936ee /Source/CPack/cmCPackLog.cxx
parent1bb7474abac4eb3aa7dd1b52d9d09d2205e104f3 (diff)
downloadCMake-44867a8c013a2ae6b828ef12af8e81cb73795483.zip
CMake-44867a8c013a2ae6b828ef12af8e81cb73795483.tar.gz
CMake-44867a8c013a2ae6b828ef12af8e81cb73795483.tar.bz2
Modernize memory management
Update internals of various classes.
Diffstat (limited to 'Source/CPack/cmCPackLog.cxx')
-rw-r--r--Source/CPack/cmCPackLog.cxx40
1 files changed, 12 insertions, 28 deletions
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx
index ca675fd..49e4113 100644
--- a/Source/CPack/cmCPackLog.cxx
+++ b/Source/CPack/cmCPackLog.cxx
@@ -4,54 +4,38 @@
#include <iostream>
+#include <cm/memory>
+
#include "cmGeneratedFileStream.h"
#include "cmSystemTools.h"
cmCPackLog::cmCPackLog()
{
- this->Verbose = false;
- this->Debug = false;
- this->Quiet = false;
- this->NewLine = true;
-
- this->LastTag = cmCPackLog::NOTAG;
this->DefaultOutput = &std::cout;
this->DefaultError = &std::cerr;
-
- this->LogOutput = nullptr;
- this->LogOutputCleanup = false;
}
-cmCPackLog::~cmCPackLog()
-{
- this->SetLogOutputStream(nullptr);
-}
+cmCPackLog::~cmCPackLog() = default;
void cmCPackLog::SetLogOutputStream(std::ostream* os)
{
- if (this->LogOutputCleanup && this->LogOutput) {
- delete this->LogOutput;
- }
- this->LogOutputCleanup = false;
+ this->LogOutputStream.reset();
this->LogOutput = os;
}
bool cmCPackLog::SetLogOutputFile(const char* fname)
{
- cmGeneratedFileStream* cg = nullptr;
+ this->LogOutputStream.reset();
if (fname) {
- cg = new cmGeneratedFileStream(fname);
- }
- if (cg && !*cg) {
- delete cg;
- cg = nullptr;
+ this->LogOutputStream = cm::make_unique<cmGeneratedFileStream>(fname);
}
- this->SetLogOutputStream(cg);
- if (!cg) {
- return false;
+ if (this->LogOutputStream && !*this->LogOutputStream) {
+ this->LogOutputStream.reset();
}
- this->LogOutputCleanup = true;
- return true;
+
+ this->LogOutput = this->LogOutputStream.get();
+
+ return this->LogOutput != nullptr;
}
void cmCPackLog::Log(int tag, const char* file, int line, const char* msg,