[PATCH] D50223: [Support] Add zlib::compress which operates on std::unique_ptr<uint8_t[]>
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 3 12:28:27 PDT 2018
MaskRay updated this revision to Diff 159067.
MaskRay added a comment.
Use set_size
Repository:
rL LLVM
https://reviews.llvm.org/D50223
Files:
lib/Support/Compression.cpp
Index: lib/Support/Compression.cpp
===================================================================
--- lib/Support/Compression.cpp
+++ lib/Support/Compression.cpp
@@ -61,15 +61,15 @@
SmallVectorImpl<char> &CompressedBuffer,
CompressionLevel Level) {
unsigned long CompressedSize = ::compressBound(InputBuffer.size());
- CompressedBuffer.resize(CompressedSize);
+ CompressedBuffer.reserve(CompressedSize);
int CLevel = encodeZlibCompressionLevel(Level);
int Res = ::compress2((Bytef *)CompressedBuffer.data(), &CompressedSize,
(const Bytef *)InputBuffer.data(), InputBuffer.size(),
CLevel);
// Tell MemorySanitizer that zlib output buffer is fully initialized.
// This avoids a false report when running LLVM with uninstrumented ZLib.
__msan_unpoison(CompressedBuffer.data(), CompressedSize);
- CompressedBuffer.resize(CompressedSize);
+ CompressedBuffer.set_size(CompressedSize);
return Res ? createError(convertZlibCodeToString(Res)) : Error::success();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50223.159067.patch
Type: text/x-patch
Size: 1083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180803/121eb5c2/attachment.bin>
More information about the llvm-commits
mailing list