diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-01-02 16:07:09 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-01-07 10:03:11 (GMT) |
commit | a00960288bedb3cd9495222e7917c9a1092ce4c9 (patch) | |
tree | 03843ce4517050e051c1a225912841c5dabb8174 /Source/cmGlobalVisualStudio9Generator.cxx | |
parent | e353d8bd9bfd90396089e514d5b77f027ac27e99 (diff) | |
download | CMake-a00960288bedb3cd9495222e7917c9a1092ce4c9.zip CMake-a00960288bedb3cd9495222e7917c9a1092ce4c9.tar.gz CMake-a00960288bedb3cd9495222e7917c9a1092ce4c9.tar.bz2 |
GlobalGenerator family: modernize memory management
Diffstat (limited to 'Source/cmGlobalVisualStudio9Generator.cxx')
-rw-r--r-- | Source/cmGlobalVisualStudio9Generator.cxx | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx index 6e61d26..9f73c15 100644 --- a/Source/cmGlobalVisualStudio9Generator.cxx +++ b/Source/cmGlobalVisualStudio9Generator.cxx @@ -2,6 +2,8 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmGlobalVisualStudio9Generator.h" +#include <utility> + #include "cmDocumentationEntry.h" #include "cmLocalVisualStudio7Generator.h" #include "cmMakefile.h" @@ -13,43 +15,46 @@ static const char vs9generatorName[] = "Visual Studio 9 2008"; class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory { public: - cmGlobalGenerator* CreateGlobalGenerator(const std::string& name, - cmake* cm) const override + std::unique_ptr<cmGlobalGenerator> CreateGlobalGenerator( + const std::string& name, cmake* cm) const override { if (strncmp(name.c_str(), vs9generatorName, sizeof(vs9generatorName) - 1) != 0) { - return 0; + return std::unique_ptr<cmGlobalGenerator>(); } const char* p = name.c_str() + sizeof(vs9generatorName) - 1; if (p[0] == '\0') { - return new cmGlobalVisualStudio9Generator(cm, name, ""); + return std::unique_ptr<cmGlobalGenerator>( + new cmGlobalVisualStudio9Generator(cm, name, "")); } if (p[0] != ' ') { - return 0; + return std::unique_ptr<cmGlobalGenerator>(); } ++p; if (!strcmp(p, "IA64")) { - return new cmGlobalVisualStudio9Generator(cm, name, "Itanium"); + return std::unique_ptr<cmGlobalGenerator>( + new cmGlobalVisualStudio9Generator(cm, name, "Itanium")); } if (!strcmp(p, "Win64")) { - return new cmGlobalVisualStudio9Generator(cm, name, "x64"); + return std::unique_ptr<cmGlobalGenerator>( + new cmGlobalVisualStudio9Generator(cm, name, "x64")); } cmVisualStudioWCEPlatformParser parser(p); parser.ParseVersion("9.0"); if (!parser.Found()) { - return 0; + return std::unique_ptr<cmGlobalGenerator>(); } - cmGlobalVisualStudio9Generator* ret = - new cmGlobalVisualStudio9Generator(cm, name, p); + auto ret = std::unique_ptr<cmGlobalVisualStudio9Generator>( + new cmGlobalVisualStudio9Generator(cm, name, p)); ret->WindowsCEVersion = parser.GetOSVersion(); - return ret; + return std::unique_ptr<cmGlobalGenerator>(std::move(ret)); } void GetDocumentation(cmDocumentationEntry& entry) const override @@ -103,9 +108,10 @@ public: std::string GetDefaultPlatformName() const override { return "Win32"; } }; -cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory() +std::unique_ptr<cmGlobalGeneratorFactory> +cmGlobalVisualStudio9Generator::NewFactory() { - return new Factory; + return std::unique_ptr<cmGlobalGeneratorFactory>(new Factory); } cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator( |