Skip to content

Commit

Permalink
Merge pull request #2555 from senhuang42/default_clevel_func
Browse files Browse the repository at this point in the history
Add ZSTD_defaultCLevel() function to public API
  • Loading branch information
senhuang42 authored Mar 25, 2021
2 parents f8ac0ea + e398744 commit b0407b9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions doc/zstd_manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,11 @@ <h3>Streaming decompression functions</h3><pre></pre><b><pre></pre></b><BR>
which have troubles handling structures containing memory pointers.

</p></pre><BR>

<pre><b>int ZSTD_defaultCLevel();
</b><p> Returns the default compression level, specified by ZSTD_CLEVEL_DEFAULT

</p></pre><BR>

<a name="Chapter18"></a><h2>Advanced decompression functions</h2><pre></pre>

Expand Down
1 change: 1 addition & 0 deletions lib/compress/zstd_compress.c
Original file line number Diff line number Diff line change
Expand Up @@ -5789,6 +5789,7 @@ size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output)
#define ZSTD_MAX_CLEVEL 22
int ZSTD_maxCLevel(void) { return ZSTD_MAX_CLEVEL; }
int ZSTD_minCLevel(void) { return (int)-ZSTD_TARGETLENGTH_MAX; }
int ZSTD_defaultCLevel(void) { return ZSTD_CLEVEL_DEFAULT; }

static const ZSTD_compressionParameters ZSTD_defaultCParameters[4][ZSTD_MAX_CLEVEL+1] = {
{ /* "default" - for any srcSize > 256 KB */
Expand Down
4 changes: 4 additions & 0 deletions lib/zstd.h
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,10 @@ ZSTDLIB_API size_t ZSTD_compressStream2_simpleArgs (
const void* src, size_t srcSize, size_t* srcPos,
ZSTD_EndDirective endOp);

/*! ZSTD_defaultCLevel() :
* Returns the default compression level, specified by ZSTD_CLEVEL_DEFAULT
*/
ZSTDLIB_API int ZSTD_defaultCLevel(void);

/***************************************
* Advanced decompression functions
Expand Down
6 changes: 6 additions & 0 deletions tests/fuzzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,12 @@ static int basicUnitTests(U32 const seed, double compressibility)
DISPLAYLEVEL(3, "%i (OK) \n", mcl);
}

DISPLAYLEVEL(3, "test%3u : default compression level : ", testNb++);
{ int const defaultCLevel = ZSTD_defaultCLevel();
if (defaultCLevel != ZSTD_CLEVEL_DEFAULT) goto _output_error;
DISPLAYLEVEL(3, "%i (OK) \n", defaultCLevel);
}

DISPLAYLEVEL(3, "test%3u : ZSTD_versionNumber : ", testNb++);
{ unsigned const vn = ZSTD_versionNumber();
DISPLAYLEVEL(3, "%u (OK) \n", vn);
Expand Down

0 comments on commit b0407b9

Please sign in to comment.