@@ -140,16 +140,16 @@ static void php_image_filter_pixelate(INTERNAL_FUNCTION_PARAMETERS);
140140static void php_image_filter_scatter (INTERNAL_FUNCTION_PARAMETERS );
141141
142142/* End Section filters declarations */
143- static gdImagePtr _php_image_create_from_string (zend_string * Data , char * tn , gdImagePtr (* ioctx_func_p )());
144- static void _php_image_create_from (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , gdImagePtr (* func_p )(), gdImagePtr (* ioctx_func_p )());
145- static void _php_image_output (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , void ( * func_p )() );
143+ static gdImagePtr _php_image_create_from_string (zend_string * Data , char * tn , gdImagePtr (* ioctx_func_p )(gdIOCtxPtr ));
144+ static void _php_image_create_from (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , gdImagePtr (* func_p )(FILE * ), gdImagePtr (* ioctx_func_p )(gdIOCtxPtr ));
145+ static void _php_image_output (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn );
146146static gdIOCtx * create_stream_context_from_zval (zval * to_zval );
147147static gdIOCtx * create_stream_context (php_stream * stream , int close_stream );
148148static gdIOCtx * create_output_context (void );
149149static int _php_image_type (zend_string * data );
150150
151151/* output streaming (formerly gd_ctx.c) */
152- static void _php_image_output_ctx (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , void ( * func_p )() );
152+ static void _php_image_output_ctx (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn );
153153
154154/*********************************************************
155155 *
@@ -291,7 +291,7 @@ static zend_function *php_gd_font_object_get_constructor(zend_object *object)
291291 return NULL ;
292292}
293293
294- static void php_gd_font_minit_helper ()
294+ static void php_gd_font_minit_helper (void )
295295{
296296 gd_font_ce = register_class_GdFont ();
297297 gd_font_ce -> create_object = php_gd_font_object_create ;
@@ -1524,7 +1524,7 @@ static int _php_image_type(zend_string *data)
15241524/* }}} */
15251525
15261526/* {{{ _php_image_create_from_string */
1527- gdImagePtr _php_image_create_from_string (zend_string * data , char * tn , gdImagePtr (* ioctx_func_p )())
1527+ gdImagePtr _php_image_create_from_string (zend_string * data , char * tn , gdImagePtr (* ioctx_func_p )(gdIOCtxPtr ))
15281528{
15291529 gdImagePtr im ;
15301530 gdIOCtx * io_ctx ;
@@ -1629,7 +1629,7 @@ PHP_FUNCTION(imagecreatefromstring)
16291629/* }}} */
16301630
16311631/* {{{ _php_image_create_from */
1632- static void _php_image_create_from (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , gdImagePtr (* func_p )(), gdImagePtr (* ioctx_func_p )())
1632+ static void _php_image_create_from (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , gdImagePtr (* func_p )(FILE * ), gdImagePtr (* ioctx_func_p )(gdIOCtxPtr ))
16331633{
16341634 char * file ;
16351635 size_t file_len ;
@@ -1673,7 +1673,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
16731673 if (FAILURE == php_stream_cast (stream , PHP_STREAM_AS_STDIO , (void * * )& fp , REPORT_ERRORS )) {
16741674 goto out_err ;
16751675 }
1676- } else if (ioctx_func_p ) {
1676+ } else if (ioctx_func_p || image_type == PHP_GDIMG_TYPE_GD2PART ) {
16771677 /* we can create an io context */
16781678 gdIOCtx * io_ctx ;
16791679 zend_string * buff ;
@@ -1697,7 +1697,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
16971697 }
16981698
16991699 if (image_type == PHP_GDIMG_TYPE_GD2PART ) {
1700- im = ( * ioctx_func_p ) (io_ctx , srcx , srcy , width , height );
1700+ im = gdImageCreateFromGd2PartCtx (io_ctx , srcx , srcy , width , height );
17011701 } else {
17021702 im = (* ioctx_func_p )(io_ctx );
17031703 }
@@ -1715,7 +1715,7 @@ static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type,
17151715 if (!im && fp ) {
17161716 switch (image_type ) {
17171717 case PHP_GDIMG_TYPE_GD2PART :
1718- im = ( * func_p ) (fp , srcx , srcy , width , height );
1718+ im = gdImageCreateFromGd2Part (fp , srcx , srcy , width , height );
17191719 break ;
17201720#ifdef HAVE_GD_XPM
17211721 case PHP_GDIMG_TYPE_XPM :
@@ -1807,7 +1807,7 @@ PHP_FUNCTION(imagecreatefromavif)
18071807/* {{{ Create a new image from XPM file or URL */
18081808PHP_FUNCTION (imagecreatefromxpm )
18091809{
1810- _php_image_create_from (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_XPM , "XPM" , gdImageCreateFromXpm , NULL );
1810+ _php_image_create_from (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_XPM , "XPM" , NULL , NULL );
18111811}
18121812/* }}} */
18131813#endif
@@ -1836,7 +1836,7 @@ PHP_FUNCTION(imagecreatefromgd2)
18361836/* {{{ Create a new image from a given part of GD2 file or URL */
18371837PHP_FUNCTION (imagecreatefromgd2part )
18381838{
1839- _php_image_create_from (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_GD2PART , "GD2" , gdImageCreateFromGd2Part , gdImageCreateFromGd2PartCtx );
1839+ _php_image_create_from (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_GD2PART , "GD2" , NULL , NULL );
18401840}
18411841/* }}} */
18421842
@@ -1859,7 +1859,7 @@ PHP_FUNCTION(imagecreatefromtga)
18591859#endif
18601860
18611861/* {{{ _php_image_output */
1862- static void _php_image_output (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , void ( * func_p )() )
1862+ static void _php_image_output (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn )
18631863{
18641864 zval * imgind ;
18651865 char * file = NULL ;
@@ -1906,13 +1906,13 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
19061906
19071907 switch (image_type ) {
19081908 case PHP_GDIMG_TYPE_GD :
1909- ( * func_p ) (im , fp );
1909+ gdImageGd (im , fp );
19101910 break ;
19111911 case PHP_GDIMG_TYPE_GD2 :
19121912 if (q == -1 ) {
19131913 q = 128 ;
19141914 }
1915- ( * func_p ) (im , fp , q , t );
1915+ gdImageGd2 (im , fp , q , t );
19161916 break ;
19171917 EMPTY_SWITCH_DEFAULT_CASE ()
19181918 }
@@ -1932,13 +1932,13 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
19321932
19331933 switch (image_type ) {
19341934 case PHP_GDIMG_TYPE_GD :
1935- ( * func_p ) (im , tmp );
1935+ gdImageGd (im , tmp );
19361936 break ;
19371937 case PHP_GDIMG_TYPE_GD2 :
19381938 if (q == -1 ) {
19391939 q = 128 ;
19401940 }
1941- ( * func_p ) (im , tmp , q , t );
1941+ gdImageGd2 (im , tmp , q , t );
19421942 break ;
19431943 EMPTY_SWITCH_DEFAULT_CASE ()
19441944 }
@@ -2008,15 +2008,15 @@ PHP_FUNCTION(imagexbm)
20082008/* {{{ Output GIF image to browser or file */
20092009PHP_FUNCTION (imagegif )
20102010{
2011- _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_GIF , "GIF" , gdImageGifCtx );
2011+ _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_GIF , "GIF" );
20122012}
20132013/* }}} */
20142014
20152015#ifdef HAVE_GD_PNG
20162016/* {{{ Output PNG image to browser or file */
20172017PHP_FUNCTION (imagepng )
20182018{
2019- _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_PNG , "PNG" , gdImagePngCtxEx );
2019+ _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_PNG , "PNG" );
20202020}
20212021/* }}} */
20222022#endif /* HAVE_GD_PNG */
@@ -2025,7 +2025,7 @@ PHP_FUNCTION(imagepng)
20252025/* {{{ Output WEBP image to browser or file */
20262026PHP_FUNCTION (imagewebp )
20272027{
2028- _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_WEBP , "WEBP" , gdImageWebpCtx );
2028+ _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_WEBP , "WEBP" );
20292029}
20302030/* }}} */
20312031#endif /* HAVE_GD_WEBP */
@@ -2034,7 +2034,7 @@ PHP_FUNCTION(imagewebp)
20342034/* {{{ Output AVIF image to browser or file */
20352035PHP_FUNCTION (imageavif )
20362036{
2037- _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_AVIF , "AVIF" , gdImageAvifCtx );
2037+ _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_AVIF , "AVIF" );
20382038}
20392039/* }}} */
20402040#endif /* HAVE_GD_AVIF */
@@ -2043,7 +2043,7 @@ PHP_FUNCTION(imageavif)
20432043/* {{{ Output JPEG image to browser or file */
20442044PHP_FUNCTION (imagejpeg )
20452045{
2046- _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_JPG , "JPEG" , gdImageJpegCtx );
2046+ _php_image_output_ctx (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_JPG , "JPEG" );
20472047}
20482048/* }}} */
20492049#endif /* HAVE_GD_JPG */
@@ -2095,14 +2095,14 @@ PHP_FUNCTION(imagewbmp)
20952095/* {{{ Output GD image to browser or file */
20962096PHP_FUNCTION (imagegd )
20972097{
2098- _php_image_output (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_GD , "GD" , gdImageGd );
2098+ _php_image_output (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_GD , "GD" );
20992099}
21002100/* }}} */
21012101
21022102/* {{{ Output GD2 image to browser or file */
21032103PHP_FUNCTION (imagegd2 )
21042104{
2105- _php_image_output (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_GD2 , "GD2" , gdImageGd2 );
2105+ _php_image_output (INTERNAL_FUNCTION_PARAM_PASSTHRU , PHP_GDIMG_TYPE_GD2 , "GD2" );
21062106}
21072107/* }}} */
21082108
@@ -4220,7 +4220,7 @@ static gdIOCtx *create_output_context() {
42204220 return ctx ;
42214221}
42224222
4223- static void _php_image_output_ctx (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn , void ( * func_p )() )
4223+ static void _php_image_output_ctx (INTERNAL_FUNCTION_PARAMETERS , int image_type , char * tn )
42244224{
42254225 zval * imgind ;
42264226 zend_long quality = -1 , basefilter = -1 , speed = -1 ;
@@ -4259,19 +4259,19 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
42594259
42604260 switch (image_type ) {
42614261 case PHP_GDIMG_TYPE_JPG :
4262- ( * func_p ) (im , ctx , (int ) quality );
4262+ gdImageJpegCtx (im , ctx , (int ) quality );
42634263 break ;
42644264 case PHP_GDIMG_TYPE_WEBP :
42654265 if (quality == -1 ) {
42664266 quality = 80 ;
42674267 }
4268- ( * func_p ) (im , ctx , (int ) quality );
4268+ gdImageWebpCtx (im , ctx , (int ) quality );
42694269 break ;
42704270 case PHP_GDIMG_TYPE_AVIF :
42714271 if (speed == -1 ) {
42724272 speed = 6 ;
42734273 }
4274- ( * func_p ) (im , ctx , (int ) quality , (int ) speed );
4274+ gdImageAvifCtx (im , ctx , (int ) quality , (int ) speed );
42754275 break ;
42764276#ifdef HAVE_GD_PNG
42774277 case PHP_GDIMG_TYPE_PNG :
@@ -4283,7 +4283,7 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
42834283 break ;
42844284#endif
42854285 case PHP_GDIMG_TYPE_GIF :
4286- ( * func_p ) (im , ctx );
4286+ gdImageGifCtx (im , ctx );
42874287 break ;
42884288 EMPTY_SWITCH_DEFAULT_CASE ()
42894289 }
0 commit comments