diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2020-02-26 14:52:47 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2020-02-27 10:11:30 (GMT) |
commit | 557cecdc3d9ace51229b3dfce4a2ed71c2cc5c5c (patch) | |
tree | 656e2b8567e3c12c115bd1922f6bddb43c18a811 /Source/cmDependsJavaParserHelper.cxx | |
parent | ab2d170c746d7cb68c39e9577cdaabc66668c0aa (diff) | |
download | CMake-557cecdc3d9ace51229b3dfce4a2ed71c2cc5c5c.zip CMake-557cecdc3d9ace51229b3dfce4a2ed71c2cc5c5c.tar.gz CMake-557cecdc3d9ace51229b3dfce4a2ed71c2cc5c5c.tar.bz2 |
Modernize memory management
Update internals of various classes
Diffstat (limited to 'Source/cmDependsJavaParserHelper.cxx')
-rw-r--r-- | Source/cmDependsJavaParserHelper.cxx | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 516bbbf..fc1bbdd 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -8,6 +8,7 @@ #include <iostream> #include <utility> +#include <cm/memory> #include <cm/string_view> #include "cmsys/FStream.hxx" @@ -169,10 +170,11 @@ void cmDependsJavaParserHelper::AllocateParserType( return; } this->UnionsAvailable++; - pt->str = new char[len + 1]; + auto up = cm::make_unique<char[]>(len + 1); + pt->str = up.get(); strncpy(pt->str, str, len); pt->str[len] = 0; - this->Allocates.push_back(pt->str); + this->Allocates.push_back(std::move(up)); } void cmDependsJavaParserHelper::StartClass(const char* cls) @@ -275,10 +277,7 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb) void cmDependsJavaParserHelper::CleanupParser() { - for (char* allocate : this->Allocates) { - delete[] allocate; - } - this->Allocates.erase(this->Allocates.begin(), this->Allocates.end()); + this->Allocates.clear(); } int cmDependsJavaParserHelper::LexInput(char* buf, int maxlen) |