@@ -86,16 +86,6 @@ static zend_function_entry brotli_functions[] = {
86
86
87
87
static const size_t PHP_BROTLI_BUFFER_SIZE = 1 << 19 ;
88
88
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
-
99
89
struct _php_brotli_context {
100
90
BrotliEncoderState * encoder ;
101
91
BrotliDecoderState * decoder ;
@@ -153,6 +143,16 @@ static int php_brotli_context_create_encoder(php_brotli_context *ctx,
153
143
return SUCCESS ;
154
144
}
155
145
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
+
156
156
static void php_brotli_context_close (php_brotli_context * ctx )
157
157
{
158
158
if (ctx -> encoder ) {
@@ -788,7 +788,7 @@ php_stream_brotli_opener(
788
788
789
789
return php_stream_alloc (& php_stream_brotli_write_ops , self , NULL , mode );
790
790
} else {
791
- if (php_brotli_decoder_create (& self -> ctx . decoder ) != SUCCESS ) {
791
+ if (php_brotli_context_create_decoder (& self -> ctx ) != SUCCESS ) {
792
792
php_error_docref (NULL , E_WARNING ,
793
793
"brotli: decompression context failed" );
794
794
php_stream_close (self -> stream );
@@ -1350,7 +1350,7 @@ static ZEND_FUNCTION(brotli_uncompress_init)
1350
1350
1351
1351
PHP_BROTLI_CONTEXT_OBJ_INIT_OF_CLASS (php_brotli_uncompress_context_ce );
1352
1352
1353
- if (php_brotli_decoder_create ( & ctx -> decoder ) != SUCCESS ) {
1353
+ if (php_brotli_context_create_decoder ( ctx ) != SUCCESS ) {
1354
1354
php_error_docref (NULL , E_WARNING ,
1355
1355
"Brotli incremental uncompress init failed" );
1356
1356
RETURN_FALSE ;
0 commit comments