From: Nick Terrell <terrelln@fb.com>
Date: Thu, 17 Nov 2016 21:18:48 +0000 (-0800)
Subject: Replace deprecated LZ4 functions
X-Git-Tag: v2016.11.21.00~17
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=db777d6b97ec08fdbf461679acf46a9d8ffab62a;p=folly.git

Replace deprecated LZ4 functions

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
---

diff --git a/folly/io/Compression.cpp b/folly/io/Compression.cpp
index 9e86c4c0..c7c4c8f8 100644
--- a/folly/io/Compression.cpp
+++ b/folly/io/Compression.cpp
@@ -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);