Skip to content

Commit f9f707c

Browse files
committed
refactor: zstd_compress_init() using php_zstd_context_create_compress()
1 parent cb6a848 commit f9f707c

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

zstd.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -621,20 +621,10 @@ ZEND_FUNCTION(zstd_compress_init)
621621

622622
PHP_ZSTD_CONTEXT_OBJ_INIT_OF_CLASS(php_zstd_compress_context_ce);
623623

624-
ctx->cctx = ZSTD_createCCtx();
625-
if (ctx->cctx == NULL) {
624+
if (php_zstd_context_create_compress(ctx, level, NULL) != SUCCESS) {
626625
zval_ptr_dtor(return_value);
627-
ZSTD_WARNING("failed to create compress context");
628626
RETURN_FALSE;
629627
}
630-
ctx->cdict = NULL;
631-
632-
ZSTD_CCtx_reset(ctx->cctx, ZSTD_reset_session_only);
633-
ZSTD_CCtx_setParameter(ctx->cctx, ZSTD_c_compressionLevel, level);
634-
635-
ctx->output.size = ZSTD_CStreamOutSize();
636-
ctx->output.dst = emalloc(ctx->output.size);
637-
ctx->output.pos = 0;
638628
}
639629

640630
ZEND_FUNCTION(zstd_compress_add)

0 commit comments

Comments
 (0)