Only the CCtx Itself Needs to be Cleared during Static CCtx Init

dev
W. Felix Handte 2019-08-14 11:35:53 -04:00
parent 88c2fcd0ee
commit 58b69ab15c
1 changed files with 1 additions and 1 deletions

View File

@ -281,7 +281,7 @@ ZSTD_CCtx* ZSTD_initStaticCCtx(void *workspace, size_t workspaceSize)
ZSTD_CCtx* const cctx = (ZSTD_CCtx*) workspace;
if (workspaceSize <= sizeof(ZSTD_CCtx)) return NULL; /* minimum size */
if ((size_t)workspace & 7) return NULL; /* must be 8-aligned */
memset(workspace, 0, workspaceSize); /* may be a bit generous, could memset be smaller ? */ /* TODO(felixh): investigate */
memset(cctx, 0, sizeof(ZSTD_CCtx));
cctx->staticSize = workspaceSize;
ZSTD_workspace_init(&cctx->workspace, (void*)(cctx+1), workspaceSize - sizeof(ZSTD_CCtx));