summaryrefslogtreecommitdiffstats
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2016-09-23 20:03:49 (GMT)
committerDaniel Pfeifer <daniel@pfeifer-mail.de>2016-09-23 20:03:49 (GMT)
commit6ed564577dd0fffdd7dabfaa0ba14e2518c26048 (patch)
tree76feb1f9b232c7a7bd8ec41b40f659f584b5bcfd /Source/cmCTest.cxx
parent6757e6608992354300d635a96fed29800a4856c3 (diff)
downloadCMake-6ed564577dd0fffdd7dabfaa0ba14e2518c26048.zip
CMake-6ed564577dd0fffdd7dabfaa0ba14e2518c26048.tar.gz
CMake-6ed564577dd0fffdd7dabfaa0ba14e2518c26048.tar.bz2
CTest::Base64EncodeFile: Avoid manual delete
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx19
1 files changed, 7 insertions, 12 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 6523e3e..d058ca7 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1506,22 +1506,17 @@ std::string cmCTest::Base64EncodeFile(std::string const& file)
| std::ios::binary
#endif
);
- unsigned char* file_buffer = new unsigned char[len + 1];
- ifs.read(reinterpret_cast<char*>(file_buffer), len);
+ std::vector<char> file_buffer(len + 1);
+ ifs.read(&file_buffer[0], len);
ifs.close();
- unsigned char* encoded_buffer = new unsigned char[(len * 3) / 2 + 5];
+ std::vector<char> encoded_buffer((len * 3) / 2 + 5);
- size_t const rlen = cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
+ size_t const rlen = cmsysBase64_Encode(
+ reinterpret_cast<unsigned char*>(&file_buffer[0]), len,
+ reinterpret_cast<unsigned char*>(&encoded_buffer[0]), 1);
- std::string base64 = "";
- for (size_t i = 0; i < rlen; i++) {
- base64 += encoded_buffer[i];
- }
- delete[] file_buffer;
- delete[] encoded_buffer;
-
- return base64;
+ return std::string(&encoded_buffer[0], rlen);
}
bool cmCTest::SubmitExtraFiles(const VectorOfStrings& files)