~mmach/netext73/lz4

« back to all changes in this revision

Viewing changes to tests/roundTripTest.c

  • Committer: mmach
  • Date: 2022-11-09 18:52:10 UTC
  • Revision ID: netbit73@gmail.com-20221109185210-w358idlhh0phq688
1.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2016-present, Yann Collet, Facebook, Inc.
 
2
 * Copyright (c) 2016-2020, Yann Collet, Facebook, Inc.
3
3
 * All rights reserved.
4
4
 *
5
5
 * This source code is licensed under both the BSD-style license (found in the
6
6
 * LICENSE file in the root directory of this source tree) and the GPLv2 (found
7
 
 * in the COPYING file in the root directory of this source tree).
8
 
 * You may select, at your option, one of the above-listed licenses.
 
7
 * in the COPYING file in the root directory of this source tree),
 
8
 * meaning you may select, at your option, one of the above-listed licenses.
9
9
 */
10
10
 
11
11
/*
104
104
                          int clevel)
105
105
{
106
106
    int const proposed_clevel = clevel ? clevel : select_clevel(srcBuff, srcSize);
107
 
    int const selected_clevel = proposed_clevel < 0 ? -proposed_clevel : proposed_clevel;   /* if level < 0, it becomes an accelearion value */
 
107
    int const selected_clevel = proposed_clevel < 0 ? -proposed_clevel : proposed_clevel;   /* if level < 0, it becomes an acceleration value */
108
108
    compressFn compress = selected_clevel >= LZ4HC_CLEVEL_MIN ? LZ4_compress_HC : LZ4_compress_fast;
109
109
    int const cSize = compress((const char*)srcBuff, (char*)compressedBuff, (int)srcSize, (int)compressedBuffCapacity, selected_clevel);
110
110
    CONTROL_MSG(cSize == 0, "Compression error !");
126
126
 
127
127
static void roundTripCheck(const void* srcBuff, size_t srcSize, int clevel)
128
128
{
129
 
    size_t const cBuffSize = LZ4_compressBound((int)srcSize);
 
129
    size_t const cBuffSize = LZ4_COMPRESSBOUND(srcSize);
130
130
    void* const cBuff = malloc(cBuffSize);
131
131
    void* const rBuff = malloc(cBuffSize);
132
132