diff options
author | Brad King <brad.king@kitware.com> | 2019-07-15 11:39:47 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-07-15 11:40:00 (GMT) |
commit | a92b7fd46bcf1ecd255290d84c691a244c8ecb26 (patch) | |
tree | 13d56424cfcf969d0afaab6762a76656e0d995f0 /Source/cmLoadCommandCommand.cxx | |
parent | 3376067bae3972b0fc7232b524ee80e2fc39950f (diff) | |
parent | 1591f138f1a40fccdde7fb2796ee2d2d8f3f97bb (diff) | |
download | CMake-a92b7fd46bcf1ecd255290d84c691a244c8ecb26.zip CMake-a92b7fd46bcf1ecd255290d84c691a244c8ecb26.tar.gz CMake-a92b7fd46bcf1ecd255290d84c691a244c8ecb26.tar.bz2 |
Merge topic 'modernize-cmCommand-memory-management'
1591f138f1 modernize: manage cmCommand instances using unique_ptr.
d9b2c7dae2 Introduce memory management helper: cm_memory.hxx
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Sebastian Holtermann <sebholt@web.de>
Merge-request: !3513
Diffstat (limited to 'Source/cmLoadCommandCommand.cxx')
-rw-r--r-- | Source/cmLoadCommandCommand.cxx | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 69751b6..235dcd4 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -3,10 +3,14 @@ #include "cmLoadCommandCommand.h" #include <signal.h> + #include <sstream> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <utility> + +#include "cm_memory.hxx" #include "cmCPluginAPI.cxx" #include "cmCPluginAPI.h" @@ -39,12 +43,12 @@ public: /** * This is a virtual constructor for the command. */ - cmCommand* Clone() override + std::unique_ptr<cmCommand> Clone() override { - cmLoadedCommand* newC = new cmLoadedCommand; + auto newC = cm::make_unique<cmLoadedCommand>(); // we must copy when we clone memcpy(&newC->info, &this->info, sizeof(info)); - return newC; + return std::unique_ptr<cmLoadedCommand>(std::move(newC)); } /** @@ -237,9 +241,9 @@ bool cmLoadCommandCommand::InitialPass(std::vector<std::string> const& args, // function blocker if (initFunction) { // create a function blocker and set it up - cmLoadedCommand* f = new cmLoadedCommand(); + auto f = cm::make_unique<cmLoadedCommand>(); (*initFunction)(&f->info); - this->Makefile->GetState()->AddScriptedCommand(args[0], f); + this->Makefile->GetState()->AddScriptedCommand(args[0], std::move(f)); return true; } this->SetError("Attempt to load command failed. " |