Deprecate advanced streaming functions (#3408)
* deprecate advanced streaming functions * remove internal usage of the deprecated functions * nit * suppress warnings in tests/zstreamtest.c * purge ZSTD_initDStream_usingDict * nits * c90 compat * zstreamtest.c already disables deprecation warnings! * fix initDStream() return value * fix typo * wasn't able to import private symbol properly, this commit works around that * new strategy for zbuff * undo zbuff deprecation warning changes * move ZSTD_DISABLE_DEPRECATE_WARNINGS from .h to .c
This commit is contained in:
@@ -1719,7 +1719,9 @@ size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t di
|
|||||||
size_t ZSTD_initDStream(ZSTD_DStream* zds)
|
size_t ZSTD_initDStream(ZSTD_DStream* zds)
|
||||||
{
|
{
|
||||||
DEBUGLOG(4, "ZSTD_initDStream");
|
DEBUGLOG(4, "ZSTD_initDStream");
|
||||||
return ZSTD_initDStream_usingDDict(zds, NULL);
|
FORWARD_IF_ERROR(ZSTD_DCtx_reset(zds, ZSTD_reset_session_only), "");
|
||||||
|
FORWARD_IF_ERROR(ZSTD_DCtx_refDDict(zds, NULL), "");
|
||||||
|
return ZSTD_startingInputLength(zds->format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ZSTD_initDStream_usingDDict() :
|
/* ZSTD_initDStream_usingDDict() :
|
||||||
@@ -1727,6 +1729,7 @@ size_t ZSTD_initDStream(ZSTD_DStream* zds)
|
|||||||
* this function cannot fail */
|
* this function cannot fail */
|
||||||
size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* dctx, const ZSTD_DDict* ddict)
|
size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* dctx, const ZSTD_DDict* ddict)
|
||||||
{
|
{
|
||||||
|
DEBUGLOG(4, "ZSTD_initDStream_usingDDict");
|
||||||
FORWARD_IF_ERROR( ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only) , "");
|
FORWARD_IF_ERROR( ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only) , "");
|
||||||
FORWARD_IF_ERROR( ZSTD_DCtx_refDDict(dctx, ddict) , "");
|
FORWARD_IF_ERROR( ZSTD_DCtx_refDDict(dctx, ddict) , "");
|
||||||
return ZSTD_startingInputLength(dctx->format);
|
return ZSTD_startingInputLength(dctx->format);
|
||||||
@@ -1737,6 +1740,7 @@ size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* dctx, const ZSTD_DDict* ddict)
|
|||||||
* this function cannot fail */
|
* this function cannot fail */
|
||||||
size_t ZSTD_resetDStream(ZSTD_DStream* dctx)
|
size_t ZSTD_resetDStream(ZSTD_DStream* dctx)
|
||||||
{
|
{
|
||||||
|
DEBUGLOG(4, "ZSTD_resetDStream");
|
||||||
FORWARD_IF_ERROR(ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only), "");
|
FORWARD_IF_ERROR(ZSTD_DCtx_reset(dctx, ZSTD_reset_session_only), "");
|
||||||
return ZSTD_startingInputLength(dctx->format);
|
return ZSTD_startingInputLength(dctx->format);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
/* *************************************
|
/* *************************************
|
||||||
* Dependencies
|
* Dependencies
|
||||||
***************************************/
|
***************************************/
|
||||||
|
#define ZSTD_DISABLE_DEPRECATE_WARNINGS /* suppress warning on ZSTD_initDStream_usingDict */
|
||||||
|
#include "../zstd.h" /* ZSTD_CStream, ZSTD_DStream, ZSTDLIB_API */
|
||||||
#define ZBUFF_STATIC_LINKING_ONLY
|
#define ZBUFF_STATIC_LINKING_ONLY
|
||||||
#include "zbuff.h"
|
#include "zbuff.h"
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -2510,8 +2510,8 @@ ZSTDLIB_STATIC_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx);
|
|||||||
* ZSTD_DCtx_loadDictionary(zds, dict, dictSize);
|
* ZSTD_DCtx_loadDictionary(zds, dict, dictSize);
|
||||||
*
|
*
|
||||||
* note: no dictionary will be used if dict == NULL or dictSize < 8
|
* note: no dictionary will be used if dict == NULL or dictSize < 8
|
||||||
* Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
|
|
||||||
*/
|
*/
|
||||||
|
ZSTD_DEPRECATED("use ZSTD_DCtx_reset + ZSTD_DCtx_loadDictionary, see zstd.h for detailed instructions")
|
||||||
ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
|
ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -2521,8 +2521,8 @@ ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const vo
|
|||||||
* ZSTD_DCtx_refDDict(zds, ddict);
|
* ZSTD_DCtx_refDDict(zds, ddict);
|
||||||
*
|
*
|
||||||
* note : ddict is referenced, it must outlive decompression session
|
* note : ddict is referenced, it must outlive decompression session
|
||||||
* Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
|
|
||||||
*/
|
*/
|
||||||
|
ZSTD_DEPRECATED("use ZSTD_DCtx_reset + ZSTD_DCtx_refDDict, see zstd.h for detailed instructions")
|
||||||
ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
|
ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -2531,8 +2531,8 @@ ZSTDLIB_STATIC_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const Z
|
|||||||
* ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
|
* ZSTD_DCtx_reset(zds, ZSTD_reset_session_only);
|
||||||
*
|
*
|
||||||
* re-use decompression parameters from previous init; saves dictionary loading
|
* re-use decompression parameters from previous init; saves dictionary loading
|
||||||
* Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x
|
|
||||||
*/
|
*/
|
||||||
|
ZSTD_DEPRECATED("use ZSTD_DCtx_reset, see zstd.h for detailed instructions")
|
||||||
ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
|
ZSTDLIB_STATIC_API size_t ZSTD_resetDStream(ZSTD_DStream* zds);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1995,7 +1995,8 @@ static dRess_t FIO_createDResources(FIO_prefs_t* const prefs, const char* dictFi
|
|||||||
/* dictionary */
|
/* dictionary */
|
||||||
{ void* dictBuffer;
|
{ void* dictBuffer;
|
||||||
size_t const dictBufferSize = FIO_createDictBuffer(&dictBuffer, dictFileName, prefs);
|
size_t const dictBufferSize = FIO_createDictBuffer(&dictBuffer, dictFileName, prefs);
|
||||||
CHECK( ZSTD_initDStream_usingDict(ress.dctx, dictBuffer, dictBufferSize) );
|
CHECK( ZSTD_DCtx_reset(ress.dctx, ZSTD_reset_session_only) );
|
||||||
|
CHECK( ZSTD_DCtx_loadDictionary(ress.dctx, dictBuffer, dictBufferSize) );
|
||||||
free(dictBuffer);
|
free(dictBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -428,8 +428,10 @@ static int BMK_benchMem(z_const void* srcBuffer, size_t srcSize,
|
|||||||
ZSTD_DStream* zbd = ZSTD_createDStream();
|
ZSTD_DStream* zbd = ZSTD_createDStream();
|
||||||
size_t rSize;
|
size_t rSize;
|
||||||
if (zbd == NULL) EXM_THROW(1, "ZSTD_createDStream() allocation failure");
|
if (zbd == NULL) EXM_THROW(1, "ZSTD_createDStream() allocation failure");
|
||||||
rSize = ZSTD_initDStream_usingDict(zbd, dictBuffer, dictBufferSize);
|
rSize = ZSTD_DCtx_reset(zbd, ZSTD_reset_session_only);
|
||||||
if (ZSTD_isError(rSize)) EXM_THROW(1, "ZSTD_initDStream() failed : %s", ZSTD_getErrorName(rSize));
|
if (ZSTD_isError(rSize)) EXM_THROW(1, "ZSTD_DCtx_reset() failed : %s", ZSTD_getErrorName(rSize));
|
||||||
|
rSize = ZSTD_DCtx_loadDictionary(zbd, dictBuffer, dictBufferSize);
|
||||||
|
if (ZSTD_isError(rSize)) EXM_THROW(1, "ZSTD_DCtx_loadDictionary() failed : %s", ZSTD_getErrorName(rSize));
|
||||||
do {
|
do {
|
||||||
U32 blockNb;
|
U32 blockNb;
|
||||||
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
|
for (blockNb=0; blockNb<nbBlocks; blockNb++) {
|
||||||
|
|||||||
@@ -706,8 +706,10 @@ ZEXTERN int ZEXPORT z_inflateSetDictionary _Z_OF((z_streamp strm,
|
|||||||
|
|
||||||
{ ZWRAP_DCtx* const zwd = (ZWRAP_DCtx*) strm->state;
|
{ ZWRAP_DCtx* const zwd = (ZWRAP_DCtx*) strm->state;
|
||||||
if (zwd == NULL || zwd->zbd == NULL) return Z_STREAM_ERROR;
|
if (zwd == NULL || zwd->zbd == NULL) return Z_STREAM_ERROR;
|
||||||
{ size_t const initErr = ZSTD_initDStream_usingDict(zwd->zbd, dictionary, dictLength);
|
{ size_t const resetErr = ZSTD_DCtx_reset(zwd->zbd, ZSTD_reset_session_only);
|
||||||
if (ZSTD_isError(initErr)) return ZWRAPD_finishWithError(zwd, strm, 0); }
|
if (ZSTD_isError(resetErr)) return ZWRAPD_finishWithError(zwd, strm, 0); }
|
||||||
|
{ size_t const loadErr = ZSTD_DCtx_loadDictionary(zwd->zbd, dictionary, dictLength);
|
||||||
|
if (ZSTD_isError(loadErr)) return ZWRAPD_finishWithError(zwd, strm, 0); }
|
||||||
zwd->decompState = ZWRAP_useReset;
|
zwd->decompState = ZWRAP_useReset;
|
||||||
|
|
||||||
if (zwd->totalInBytes == ZSTD_HEADERSIZE) {
|
if (zwd->totalInBytes == ZSTD_HEADERSIZE) {
|
||||||
|
|||||||
Reference in New Issue
Block a user