[llvm] r281082 - Add a lower level zlib::uncompress.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 9 12:32:37 PDT 2016
Author: rafael
Date: Fri Sep 9 14:32:36 2016
New Revision: 281082
URL: http://llvm.org/viewvc/llvm-project?rev=281082&view=rev
Log:
Add a lower level zlib::uncompress.
SmallVectors are convenient, but they don't cover every use case.
In particular, they are fairly large (3 pointers + one element) and
there is no way to take ownership of the buffer to put it somewhere
else. This patch then adds a lower lever interface that works with
any buffer.
Modified:
llvm/trunk/include/llvm/Support/Compression.h
llvm/trunk/lib/Support/Compression.cpp
Modified: llvm/trunk/include/llvm/Support/Compression.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Compression.h?rev=281082&r1=281081&r2=281082&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Compression.h (original)
+++ llvm/trunk/include/llvm/Support/Compression.h Fri Sep 9 14:32:36 2016
@@ -43,6 +43,9 @@ bool isAvailable();
Status compress(StringRef InputBuffer, SmallVectorImpl<char> &CompressedBuffer,
CompressionLevel Level = DefaultCompression);
+Status uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+ size_t &UncompressedSize);
+
Status uncompress(StringRef InputBuffer,
SmallVectorImpl<char> &UncompressedBuffer,
size_t UncompressedSize);
Modified: llvm/trunk/lib/Support/Compression.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Compression.cpp?rev=281082&r1=281081&r2=281082&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Compression.cpp (original)
+++ llvm/trunk/lib/Support/Compression.cpp Fri Sep 9 14:32:36 2016
@@ -62,16 +62,23 @@ zlib::Status zlib::compress(StringRef In
return Res;
}
+zlib::Status zlib::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+ size_t &UncompressedSize) {
+ Status Res = encodeZlibReturnValue(
+ ::uncompress((Bytef *)UncompressedBuffer, (uLongf *)&UncompressedSize,
+ (const Bytef *)InputBuffer.data(), InputBuffer.size()));
+ // Tell MemorySanitizer that zlib output buffer is fully initialized.
+ // This avoids a false report when running LLVM with uninstrumented ZLib.
+ __msan_unpoison(UncompressedBuffer, UncompressedSize);
+ return Res;
+}
+
zlib::Status zlib::uncompress(StringRef InputBuffer,
SmallVectorImpl<char> &UncompressedBuffer,
size_t UncompressedSize) {
UncompressedBuffer.resize(UncompressedSize);
- Status Res = encodeZlibReturnValue(::uncompress(
- (Bytef *)UncompressedBuffer.data(), (uLongf *)&UncompressedSize,
- (const Bytef *)InputBuffer.data(), InputBuffer.size()));
- // Tell MemorySanitizer that zlib output buffer is fully initialized.
- // This avoids a false report when running LLVM with uninstrumented ZLib.
- __msan_unpoison(UncompressedBuffer.data(), UncompressedSize);
+ Status Res =
+ uncompress(InputBuffer, UncompressedBuffer.data(), UncompressedSize);
UncompressedBuffer.resize(UncompressedSize);
return Res;
}
More information about the llvm-commits
mailing list