[Cmake-commits] CMake branch, next, updated. v3.6.2-2440-gffa78c3
Daniel Pfeifer
daniel at pfeifer-mail.de
Fri Sep 23 16:07:42 EDT 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via ffa78c37c8efccc0d73ceae0fd0c31eabca1633d (commit)
via b941f3bfe7ba3bffd535372c2a4d9d668bc83356 (commit)
via a5a7771a428a1d4a9bb671e56ea6d497361bc753 (commit)
via 6ed564577dd0fffdd7dabfaa0ba14e2518c26048 (commit)
from 3c6d4f69016e6ce48430b3d49c63857aaeb14b76 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ffa78c37c8efccc0d73ceae0fd0c31eabca1633d
commit ffa78c37c8efccc0d73ceae0fd0c31eabca1633d
Merge: 3c6d4f6 b941f3b
Author: Daniel Pfeifer <daniel at pfeifer-mail.de>
AuthorDate: Fri Sep 23 16:07:41 2016 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Fri Sep 23 16:07:41 2016 -0400
Merge topic 'ctest-no-manual-delete' into next
b941f3bf CTest::CompressString: Avoid manual delete
a5a7771a CTest::CompressString: Reorder code to avoid unnecessary allocation
6ed56457 CTest::Base64EncodeFile: Avoid manual delete
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b941f3bfe7ba3bffd535372c2a4d9d668bc83356
commit b941f3bfe7ba3bffd535372c2a4d9d668bc83356
Author: Daniel Pfeifer <daniel at pfeifer-mail.de>
AuthorDate: Fri Sep 23 22:06:17 2016 +0200
Commit: Daniel Pfeifer <daniel at pfeifer-mail.de>
CommitDate: Fri Sep 23 22:06:17 2016 +0200
CTest::CompressString: Avoid manual delete
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 0624b52..9b5248e 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2803,34 +2803,29 @@ bool cmCTest::CompressString(std::string& str)
// zlib makes the guarantee that this is the maximum output size
int outSize =
static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0);
- unsigned char* out = new unsigned char[outSize];
+ std::vector<unsigned char> out(outSize);
strm.avail_in = static_cast<uInt>(str.size());
strm.next_in = in;
strm.avail_out = outSize;
- strm.next_out = out;
+ strm.next_out = &out[0];
ret = deflate(&strm, Z_FINISH);
if (ret == Z_STREAM_ERROR || ret != Z_STREAM_END) {
cmCTestLog(this, ERROR_MESSAGE, "Error during gzip compression."
<< std::endl);
- delete[] out;
return false;
}
(void)deflateEnd(&strm);
// Now base64 encode the resulting binary string
- unsigned char* base64EncodedBuffer = new unsigned char[(outSize * 3) / 2];
+ std::vector<unsigned char> base64EncodedBuffer((outSize * 3) / 2);
size_t rlen =
- cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1);
+ cmsysBase64_Encode(&out[0], strm.total_out, &base64EncodedBuffer[0], 1);
- str = "";
- str.append(reinterpret_cast<char*>(base64EncodedBuffer), rlen);
-
- delete[] base64EncodedBuffer;
- delete[] out;
+ str.assign(reinterpret_cast<char*>(&base64EncodedBuffer[0]), rlen);
return true;
}
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a5a7771a428a1d4a9bb671e56ea6d497361bc753
commit a5a7771a428a1d4a9bb671e56ea6d497361bc753
Author: Daniel Pfeifer <daniel at pfeifer-mail.de>
AuthorDate: Fri Sep 23 22:04:47 2016 +0200
Commit: Daniel Pfeifer <daniel at pfeifer-mail.de>
CommitDate: Fri Sep 23 22:04:47 2016 +0200
CTest::CompressString: Reorder code to avoid unnecessary allocation
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index d058ca7..0624b52 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2790,22 +2790,21 @@ bool cmCTest::CompressString(std::string& str)
int ret;
z_stream strm;
- unsigned char* in =
- reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str()));
- // zlib makes the guarantee that this is the maximum output size
- int outSize =
- static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0);
- unsigned char* out = new unsigned char[outSize];
-
strm.zalloc = Z_NULL;
strm.zfree = Z_NULL;
strm.opaque = Z_NULL;
ret = deflateInit(&strm, -1); // default compression level
if (ret != Z_OK) {
- delete[] out;
return false;
}
+ unsigned char* in =
+ reinterpret_cast<unsigned char*>(const_cast<char*>(str.c_str()));
+ // zlib makes the guarantee that this is the maximum output size
+ int outSize =
+ static_cast<int>(static_cast<double>(str.size()) * 1.001 + 13.0);
+ unsigned char* out = new unsigned char[outSize];
+
strm.avail_in = static_cast<uInt>(str.size());
strm.next_in = in;
strm.avail_out = outSize;
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6ed564577dd0fffdd7dabfaa0ba14e2518c26048
commit 6ed564577dd0fffdd7dabfaa0ba14e2518c26048
Author: Daniel Pfeifer <daniel at pfeifer-mail.de>
AuthorDate: Fri Sep 23 22:03:49 2016 +0200
Commit: Daniel Pfeifer <daniel at pfeifer-mail.de>
CommitDate: Fri Sep 23 22:03:49 2016 +0200
CTest::Base64EncodeFile: Avoid manual delete
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)
-----------------------------------------------------------------------
Summary of changes:
Source/cmCTest.cxx | 47 ++++++++++++++++++-----------------------------
1 file changed, 18 insertions(+), 29 deletions(-)
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list