@@ -24,19 +24,23 @@ static void zstd_destroy(void *ctx)
24
24
kfree (zctx );
25
25
}
26
26
27
- static void * zstd_create (void )
27
+ static void * zstd_create (struct zcomp_params * params )
28
28
{
29
- zstd_parameters params ;
29
+ zstd_parameters prm ;
30
30
struct zstd_ctx * ctx ;
31
31
size_t sz ;
32
32
33
33
ctx = kzalloc (sizeof (* ctx ), GFP_KERNEL );
34
34
if (!ctx )
35
35
return NULL ;
36
36
37
- ctx -> level = zstd_default_clevel ();
38
- params = zstd_get_params (ctx -> level , PAGE_SIZE );
39
- sz = zstd_cctx_workspace_bound (& params .cParams );
37
+ if (params -> level != ZCOMP_PARAM_NO_LEVEL )
38
+ ctx -> level = params -> level ;
39
+ else
40
+ ctx -> level = zstd_default_clevel ();
41
+
42
+ prm = zstd_get_params (ctx -> level , PAGE_SIZE );
43
+ sz = zstd_cctx_workspace_bound (& prm .cParams );
40
44
ctx -> cctx_mem = vzalloc (sz );
41
45
if (!ctx -> cctx_mem )
42
46
goto error ;
@@ -65,11 +69,11 @@ static int zstd_compress(void *ctx, const unsigned char *src, size_t src_len,
65
69
unsigned char * dst , size_t * dst_len )
66
70
{
67
71
struct zstd_ctx * zctx = ctx ;
68
- const zstd_parameters params = zstd_get_params (zctx -> level , PAGE_SIZE );
72
+ const zstd_parameters prm = zstd_get_params (zctx -> level , PAGE_SIZE );
69
73
size_t ret ;
70
74
71
75
ret = zstd_compress_cctx (zctx -> cctx , dst , * dst_len ,
72
- src , src_len , & params );
76
+ src , src_len , & prm );
73
77
if (zstd_is_error (ret ))
74
78
return - EINVAL ;
75
79
* dst_len = ret ;
0 commit comments