return ZSTD_initCStream_usingDict(zcs, NULL, 0, compressionLevel);
}
+size_t ZSTD_sizeofCStream(const ZSTD_CStream* zcs)
+{
+ return sizeof(zcs) + ZSTD_sizeofCCtx(zcs->zc) + zcs->outBuffSize + zcs->inBuffSize;
+}
/*====== Compression ======*/
}
-/*-**********************************
-* Streaming Decompression API
-************************************/
+/*-**************************************
+* Advanced Streaming Decompression API
+* Bufferless and synchronous
+****************************************/
size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx) { return dctx->expected; }
ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx) {
return ZSTD_initDStream_usingDict(zds, NULL, 0);
}
+size_t ZSTD_sizeofDStream(const ZSTD_DStream* zds)
+{
+ return sizeof(*zds) + ZSTD_sizeofDCtx(zds->zd) + zds->inBuffSize + zds->outBuffSize;
+}
+
/* *** Decompression *** */
return nextSrcSizeHint;
}
}
-
-
-
-
-
-
size_t ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, const void* dict, size_t dictSize, int compressionLevel);
size_t ZSTD_initCStream_advanced(ZSTD_CStream* zcs, const void* dict, size_t dictSize,
ZSTD_parameters params, unsigned long long pledgedSrcSize);
+size_t ZSTD_sizeofCStream(const ZSTD_CStream* zcs);
+
/*====== decompression ======*/
/* advanced */
ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem);
size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize);
-
+size_t ZSTD_sizeofDStream(const ZSTD_DStream* zds);
/* ******************************************************************
return rand32 >> 5;
}
-
static unsigned FUZ_highbit32(U32 v32)
{
unsigned nbBits = 0;
}
+/*=============================================
+* Basic Unit tests
+=============================================*/
+
#define CHECK_V(var, fn) size_t const var = fn; if (ZSTD_isError(var)) goto _output_error
#define CHECK(fn) { CHECK_V(err, fn); }
#define CHECKPLUS(var, fn, more) { CHECK_V(var, fn); more; }
static const U32 prime2 = 2246822519U;
-
/*-************************************
* Display Macros
**************************************/
return nCount;
}
-
static U32 FUZ_GetMilliSpan(U32 nTimeStart)
{
U32 const nCurrent = FUZ_GetMilliStart();
return rand32 >> 5;
}
-
/*
static unsigned FUZ_highbit32(U32 v32)
{
free(address);
}
+
+/*======================================================
+* Basic Unit tests
+======================================================*/
+
static int basicUnitTests(U32 seed, double compressibility, ZSTD_customMem customMem)
{
int testResult = 0;
cSize += outBuff.pos;
DISPLAYLEVEL(4, "OK (%u bytes : %.2f%%)\n", (U32)cSize, (double)cSize/COMPRESSIBLE_NOISE_LENGTH*100);
+ DISPLAYLEVEL(4, "test%3i : check CStream size : ", testNb++);
+ { size_t const s = ZSTD_sizeofCStream(zc);
+ if (ZSTD_isError(s)) goto _output_error;
+ DISPLAYLEVEL(4, "OK (%u bytes) \n", (U32)s);
+ }
+
/* skippable frame test */
DISPLAYLEVEL(4, "test%3i : decompress skippable frame : ", testNb++);
ZSTD_initDStream_usingDict(zd, CNBuffer, 128 KB);
} }
DISPLAYLEVEL(4, "OK \n");
+ DISPLAYLEVEL(4, "test%3i : check DStream size : ", testNb++);
+ { size_t const s = ZSTD_sizeofDStream(zd);
+ if (ZSTD_isError(s)) goto _output_error;
+ DISPLAYLEVEL(4, "OK (%u bytes) \n", (U32)s);
+ }
+
/* Byte-by-byte decompression test */
DISPLAYLEVEL(4, "test%3i : decompress byte-by-byte : ", testNb++);
{ size_t r = 1;