Replace deprecated LZ4 functions
authorNick Terrell <terrelln@fb.com>
Thu, 17 Nov 2016 21:18:48 +0000 (13:18 -0800)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Thu, 17 Nov 2016 21:23:42 +0000 (13:23 -0800)
Summary:
Replace deprecated functions with their functionally equivalent counterparts.

See https://github.com/lz4/lz4/blob/dev/lib/lz4.c#L1405 and https://github.com/lz4/lz4/blob/dev/lib/lz4hc.c#L634

Reviewed By: Cyan4973

Differential Revision: D4194834

fbshipit-source-id: aa4f934c46fe764fcec8ea29221e3882da2b5cdf

folly/io/Compression.cpp

index 9e86c4c..c7c4c8f 100644 (file)
@@ -260,13 +260,18 @@ std::unique_ptr<IOBuf> LZ4Codec::doCompress(const IOBuf* data) {
 
   int n;
   if (highCompression_) {
-    n = LZ4_compressHC(reinterpret_cast<const char*>(data->data()),
-                       reinterpret_cast<char*>(out->writableTail()),
-                       data->length());
+    n = LZ4_compress_HC(
+        reinterpret_cast<const char*>(data->data()),
+        reinterpret_cast<char*>(out->writableTail()),
+        data->length(),
+        out->tailroom(),
+        0);
   } else {
-    n = LZ4_compress(reinterpret_cast<const char*>(data->data()),
-                     reinterpret_cast<char*>(out->writableTail()),
-                     data->length());
+    n = LZ4_compress_default(
+        reinterpret_cast<const char*>(data->data()),
+        reinterpret_cast<char*>(out->writableTail()),
+        data->length(),
+        out->tailroom());
   }
 
   CHECK_GE(n, 0);