Skip to content

Commit e450471

Browse files
committed
refactor: php_brotli_decoder_create() -> php_brotli_context_create_decoder()
1 parent 0572eea commit e450471

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

brotli.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,6 @@ static zend_function_entry brotli_functions[] = {
8686

8787
static const size_t PHP_BROTLI_BUFFER_SIZE = 1 << 19;
8888

89-
static int php_brotli_decoder_create(BrotliDecoderState **decoder)
90-
{
91-
*decoder = BrotliDecoderCreateInstance(NULL, NULL, NULL);
92-
if (!*decoder) {
93-
return FAILURE;
94-
}
95-
96-
return SUCCESS;
97-
}
98-
9989
struct _php_brotli_context {
10090
BrotliEncoderState *encoder;
10191
BrotliDecoderState *decoder;
@@ -153,6 +143,16 @@ static int php_brotli_context_create_encoder(php_brotli_context *ctx,
153143
return SUCCESS;
154144
}
155145

146+
static int php_brotli_context_create_decoder(php_brotli_context *ctx)
147+
{
148+
ctx->decoder = BrotliDecoderCreateInstance(NULL, NULL, NULL);
149+
if (!ctx->decoder) {
150+
return FAILURE;
151+
}
152+
153+
return SUCCESS;
154+
}
155+
156156
static void php_brotli_context_close(php_brotli_context *ctx)
157157
{
158158
if (ctx->encoder) {
@@ -788,7 +788,7 @@ php_stream_brotli_opener(
788788

789789
return php_stream_alloc(&php_stream_brotli_write_ops, self, NULL, mode);
790790
} else {
791-
if (php_brotli_decoder_create(&self->ctx.decoder) != SUCCESS) {
791+
if (php_brotli_context_create_decoder(&self->ctx) != SUCCESS) {
792792
php_error_docref(NULL, E_WARNING,
793793
"brotli: decompression context failed");
794794
php_stream_close(self->stream);
@@ -1350,7 +1350,7 @@ static ZEND_FUNCTION(brotli_uncompress_init)
13501350

13511351
PHP_BROTLI_CONTEXT_OBJ_INIT_OF_CLASS(php_brotli_uncompress_context_ce);
13521352

1353-
if (php_brotli_decoder_create(&ctx->decoder) != SUCCESS) {
1353+
if (php_brotli_context_create_decoder(ctx) != SUCCESS) {
13541354
php_error_docref(NULL, E_WARNING,
13551355
"Brotli incremental uncompress init failed");
13561356
RETURN_FALSE;

0 commit comments

Comments
 (0)