As params structure remains same for lifetime, just initialise it at init time and make it global variable. Signed-off-by: Maninder Singh <maninder1.s@xxxxxxxxxxx> Signed-off-by: Vaneet Narang <v.narang@xxxxxxxxxxx> --- crypto/zstd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crypto/zstd.c b/crypto/zstd.c index 4e9ff22..80a9e5c 100644 --- a/crypto/zstd.c +++ b/crypto/zstd.c @@ -32,6 +32,8 @@ struct zstd_ctx { void *dwksp; }; +static ZSTD_parameters params; + static ZSTD_parameters zstd_params(void) { return ZSTD_getParams(ZSTD_DEF_LEVEL, 0, 0); @@ -40,8 +42,10 @@ static ZSTD_parameters zstd_params(void) static int zstd_comp_init(struct zstd_ctx *ctx) { int ret = 0; - const ZSTD_parameters params = zstd_params(); - const size_t wksp_size = ZSTD_CCtxWorkspaceBound(params.cParams); + size_t wksp_size; + + params = zstd_params(); + wksp_size = ZSTD_CCtxWorkspaceBound(params.cParams); ctx->cwksp = vzalloc(wksp_size); if (!ctx->cwksp) { @@ -160,7 +164,6 @@ static int __zstd_compress(const u8 *src, unsigned int slen, { size_t out_len; struct zstd_ctx *zctx = ctx; - const ZSTD_parameters params = zstd_params(); out_len = ZSTD_compressCCtx(zctx->cctx, dst, *dlen, src, slen, ¶ms); if (ZSTD_isError(out_len)) -- 2.7.4