[PATCH] Add zlib (un)compression routines to LLVM

Alexey Samsonov samsonov at google.com
Thu Apr 18 03:47:55 PDT 2013


  Uploaded a new version.


================
Comment at: lib/Support/Compression.cpp:66-67
@@ +65,4 @@
+                         (const Bytef *)InputBuffer.data(), InputBuffer.size());
+  if (res != Z_OK)
+    return false;
+  UncompressedBuffer.reset(MemoryBuffer::getMemBufferCopy(
----------------
Shankar Kalpathi Easwaran wrote:
> Same here, it might be useful to return the error from zlib instead of false.
Done

================
Comment at: lib/Support/Compression.cpp:49-53
@@ +48,7 @@
+                        CLevel);
+  if (res != Z_OK)
+    return false;
+  CompressedBuffer.reset(MemoryBuffer::getMemBufferCopy(
+      StringRef(TmpBuffer.get(), CompressedSize)));
+  return true;
+#else
----------------
Shankar Kalpathi Easwaran wrote:
> it might be useful to return the error that zlib returned than returning false.
Done

================
Comment at: lib/Support/Compression.cpp:19
@@ +18,3 @@
+#include "llvm/Support/MemoryBuffer.h"
+#if HAVE_ZLIB_H
+#include <zlib.h>
----------------
Shankar Kalpathi Easwaran wrote:
> Should this be LLVM_ENABLE_ZLIB instead ?
Done

================
Comment at: lib/Support/Compression.cpp:24-27
@@ +23,6 @@
+using namespace llvm;
+
+bool zlib::compress(StringRef InputBuffer,
+                    OwningPtr<MemoryBuffer> &CompressedBuffer,
+                    CompressionLevel Level) {
+#if LLVM_ENABLE_ZLIB == 1
----------------
Shankar Kalpathi Easwaran wrote:
> Currently compress returns a failure even if zlib is not available (or) if there is a failure returned from compress2.
> 
> Would you need another function to return if zlib is available, that way you can call zlib::compress and check the return status.
> 
> if (zlib() && !compress) 
>  // failure
> 
Right, I've added zlib::isAvailable() function.


http://llvm-reviews.chandlerc.com/D683



More information about the llvm-commits mailing list