[PATCH] D24341: Add a lower level zlib::uncompress
Rafael Ávila de Espíndola via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 8 06:11:15 PDT 2016
rafael created this revision.
rafael added reviewers: dblaikie, ruiu.
rafael added a subscriber: llvm-commits.
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.
https://reviews.llvm.org/D24341
Files:
include/llvm/Support/Compression.h
lib/Support/Compression.cpp
Index: lib/Support/Compression.cpp
===================================================================
--- lib/Support/Compression.cpp
+++ lib/Support/Compression.cpp
@@ -62,16 +62,23 @@
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;
}
Index: include/llvm/Support/Compression.h
===================================================================
--- include/llvm/Support/Compression.h
+++ include/llvm/Support/Compression.h
@@ -43,6 +43,9 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24341.70690.patch
Type: text/x-patch
Size: 2181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160908/75a57fa5/attachment.bin>
More information about the llvm-commits
mailing list