created ZSTDMT_sizeof_CCtx() and POOL_sizeof()

required by ZSTD_sizeofCCtx() while adding a ZSTDMT_CCtx*
This commit is contained in:
Yann Collet
2017-06-01 17:56:14 -07:00
parent cd2892fd1e
commit c4a5a21c5c
5 changed files with 73 additions and 8 deletions
+10 -2
View File
@@ -25,6 +25,7 @@
#define HUF_STATIC_LINKING_ONLY
#include "huf.h"
#include "zstd_internal.h" /* includes zstd.h */
#include "zstdmt_compress.h"
/*-*************************************
@@ -154,8 +155,12 @@ struct ZSTD_CCtx_s {
size_t outBuffFlushedSize;
ZSTD_cStreamStage streamStage;
U32 frameEnded;
/* Multi-threading */
ZSTDMT_CCtx* mtctx;
};
ZSTD_CCtx* ZSTD_createCCtx(void)
{
return ZSTD_createCCtx_advanced(ZSTD_defaultCMem);
@@ -205,11 +210,13 @@ ZSTD_CCtx* ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize)
size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx)
{
if (cctx==NULL) return 0; /* support free on NULL */
assert(!cctx->staticSize); /* not compatible with static CCtx */
if (cctx->staticSize) return ERROR(memory_allocation); /* not compatible with static CCtx */
ZSTD_free(cctx->workSpace, cctx->customMem);
cctx->workSpace = NULL;
ZSTD_freeCDict(cctx->cdictLocal);
cctx->cdictLocal = NULL;
ZSTDMT_freeCCtx(cctx->mtctx);
cctx->mtctx = NULL;
ZSTD_free(cctx, cctx->customMem);
return 0; /* reserved as a potential error code in the future */
}
@@ -219,7 +226,8 @@ size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx)
if (cctx==NULL) return 0; /* support sizeof on NULL */
return sizeof(*cctx) + cctx->workSpaceSize
+ ZSTD_sizeof_CDict(cctx->cdictLocal)
+ cctx->outBuffSize + cctx->inBuffSize;
+ cctx->outBuffSize + cctx->inBuffSize
+ ZSTDMT_sizeof_CCtx(cctx->mtctx);
}
size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs)