Add LZ4_compress_fast_safeExtState Function
This commit is contained in:
parent
f34fb3c42d
commit
d6a3024dbb
10
lib/lz4.c
10
lib/lz4.c
@ -739,9 +739,17 @@ _clean_up:
|
||||
|
||||
int LZ4_compress_fast_extState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration)
|
||||
{
|
||||
LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)state)->internal_donotuse;
|
||||
LZ4_resetStream((LZ4_stream_t*)state);
|
||||
return LZ4_compress_fast_safeExtState(state, source, dest, inputSize, maxOutputSize, acceleration);
|
||||
}
|
||||
|
||||
|
||||
int LZ4_compress_fast_safeExtState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration)
|
||||
{
|
||||
LZ4_stream_t_internal* ctx = &((LZ4_stream_t*)state)->internal_donotuse;
|
||||
if (acceleration < 1) acceleration = ACCELERATION_DEFAULT;
|
||||
ctx->dictionary = NULL;
|
||||
ctx->dictSize = 0;
|
||||
|
||||
if (maxOutputSize >= LZ4_compressBound(inputSize)) {
|
||||
if (inputSize < LZ4_64Klimit)
|
||||
|
@ -179,13 +179,21 @@ LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int d
|
||||
|
||||
|
||||
/*!
|
||||
LZ4_compress_fast_safeExtState() :
|
||||
LZ4_compress_fast_extState() :
|
||||
Same compression function, just using an externally allocated memory space to store compression state.
|
||||
Use LZ4_sizeofState() to know how much memory must be allocated,
|
||||
and allocate it on 8-bytes boundaries (using malloc() typically).
|
||||
Then, provide it as 'void* state' to compression function.
|
||||
|
||||
Use _safeExtState variant if LZ4_resetStream() was called on the state
|
||||
buffer before being used for the first time (calls to this function leave
|
||||
the state in a safe state, so zeroing is not required between calls).
|
||||
Otherwise, using legacy _extState requires LZ4 to reinitialize the state
|
||||
internally for every call.
|
||||
*/
|
||||
LZ4LIB_API int LZ4_sizeofState(void);
|
||||
LZ4LIB_API int LZ4_compress_fast_safeExtState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user