]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Use updated lz4 compression functions
authordosomder <dosomder@users.noreply.github.com>
Sat, 12 Mar 2016 22:35:22 +0000 (23:35 +0100)
committerdosomder <dosomder@users.noreply.github.com>
Sat, 12 Mar 2016 22:57:42 +0000 (23:57 +0100)
A few functions in the lz4 library are deprecated, some are obsolete.

libarchive/archive_write_add_filter_lz4.c

index 2f08ff40d20725fc9a00fcec3ded32382f6f95c9..06ea71373dd62d57a57d16d26064e3b2aca89476 100644 (file)
@@ -379,7 +379,11 @@ archive_filter_lz4_free(struct archive_write_filter *f)
        if (data->lz4_stream != NULL) {
 #ifdef HAVE_LZ4HC_H
                if (data->compression_level >= 3)
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+                       LZ4_freeStreamHC(data->lz4_stream);
+#else
                        LZ4_freeHC(data->lz4_stream);
+#endif
                else
 #endif
 #if LZ4_VERSION_MINOR >= 3
@@ -495,13 +499,24 @@ drive_compressor_independence(struct archive_write_filter *f, const char *p,
 
 #ifdef HAVE_LZ4HC_H
        if (data->compression_level >= 4)
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+               outsize = LZ4_compress_HC(p, data->out + 4,
+                    (int)length, (int)data->block_size,
+                   data->compression_level);
+#else
                outsize = LZ4_compressHC2_limitedOutput(p, data->out + 4,
                    (int)length, (int)data->block_size,
                    data->compression_level);
+#endif
        else
 #endif
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+               outsize = LZ4_compress_default(p, data->out + 4,
+                   (int)length, (int)data->block_size);
+#else
                outsize = LZ4_compress_limitedOutput(p, data->out + 4,
                    (int)length, (int)data->block_size);
+#endif
 
        if (outsize) {
                /* The buffer is compressed. */
@@ -532,11 +547,17 @@ drive_compressor_dependence(struct archive_write_filter *f, const char *p,
        struct private_data *data = (struct private_data *)f->data;
        int outsize;
 
+#define DICT_SIZE      (64 * 1024)
 #ifdef HAVE_LZ4HC_H
        if (data->compression_level >= 3) {
                if (data->lz4_stream == NULL) {
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+                       data->lz4_stream = LZ4_createStreamHC();
+                       LZ4_resetStreamHC(data->lz4_stream, data->compression_level);
+#else
                        data->lz4_stream =
                            LZ4_createHC(data->in_buffer_allocated);
+#endif
                        if (data->lz4_stream == NULL) {
                                archive_set_error(f->archive, ENOMEM,
                                    "Can't allocate data for compression"
@@ -544,9 +565,16 @@ drive_compressor_dependence(struct archive_write_filter *f, const char *p,
                                return (ARCHIVE_FATAL);
                        }
                }
+
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+               outsize = LZ4_compress_HC_continue(
+                   data->lz4_stream, p, data->out + 4, (int)length,
+                   (int)data->block_size);
+#else
                outsize = LZ4_compressHC2_limitedOutput_continue(
                    data->lz4_stream, p, data->out + 4, (int)length,
                    (int)data->block_size, data->compression_level);
+#endif
        } else
 #endif
        {
@@ -559,9 +587,16 @@ drive_compressor_dependence(struct archive_write_filter *f, const char *p,
                                return (ARCHIVE_FATAL);
                        }
                }
+
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+               outsize = LZ4_compress_fast_continue(
+                   data->lz4_stream, p, data->out + 4, (int)length,
+                   (int)data->block_size, 1);
+#else
                outsize = LZ4_compress_limitedOutput_continue(
                    data->lz4_stream, p, data->out + 4, (int)length,
                    (int)data->block_size);
+#endif
        }
 
        if (outsize) {
@@ -585,10 +620,13 @@ drive_compressor_dependence(struct archive_write_filter *f, const char *p,
        }
 
        if (length == data->block_size) {
-#define DICT_SIZE      (64 * 1024)
 #ifdef HAVE_LZ4HC_H
                if (data->compression_level >= 3) {
+#if LZ4_VERSION_MAJOR >= 1 && LZ4_VERSION_MINOR >= 7
+                       LZ4_saveDictHC(data->lz4_stream, data->in_buffer_allocated, DICT_SIZE);
+#else
                        LZ4_slideInputBufferHC(data->lz4_stream);
+#endif
                        data->in_buffer = data->in_buffer_allocated + DICT_SIZE;
                }
                else