Port resource destructors.

Piotr Pawłow [2016-09-14 15:38:29]
Port resource destructors.
Filename
php_imlib.c
diff --git a/php_imlib.c b/php_imlib.c
index d161bfa..e9e07e9 100644
--- a/php_imlib.c
+++ b/php_imlib.c
@@ -218,41 +218,41 @@ PHP_INI_MH(OnUpdateFontCacheSize)
     }
 }

-static void _php_imlib_free_cm(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ZEND_RSRC_DTOR_FUNC(_php_imlib_free_cm)
 {
-   imlib_context_set_color_modifier(((PHP_Imlib_Color_Modifier)rsrc->ptr)->cm);
-   efree(rsrc->ptr);
+   imlib_context_set_color_modifier(((PHP_Imlib_Color_Modifier)res->ptr)->cm);
+   efree(res->ptr);
    imlib_free_color_modifier();
 }

-static void _php_imlib_free_filter(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ZEND_RSRC_DTOR_FUNC(_php_imlib_free_filter)
 {
-   imlib_context_set_filter(rsrc->ptr);
+   imlib_context_set_filter(res->ptr);
    imlib_free_filter();
 }

-static void _php_imlib_free_cr(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ZEND_RSRC_DTOR_FUNC(_php_imlib_free_cr)
 {
-   imlib_context_set_color_range(rsrc->ptr);
+   imlib_context_set_color_range(res->ptr);
    imlib_free_color_range();
 }

-static void _php_imlib_free_font(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ZEND_RSRC_DTOR_FUNC(_php_imlib_free_font)
 {
-   imlib_context_set_font(((PHP_Imlib_Font)rsrc->ptr)->font);
-   efree(rsrc->ptr);
+   imlib_context_set_font(((PHP_Imlib_Font)res->ptr)->font);
+   efree(res->ptr);
    imlib_free_font();
 }

-static void _php_imlib_free_img(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ZEND_RSRC_DTOR_FUNC(_php_imlib_free_img)
 {
-   imlib_context_set_image(rsrc->ptr);
+   imlib_context_set_image(res->ptr);
    imlib_free_image();
 }

-static void _php_imlib_free_poly(zend_rsrc_list_entry *rsrc TSRMLS_DC)
+ZEND_RSRC_DTOR_FUNC(_php_imlib_free_poly)
 {
-   imlib_polygon_free(rsrc->ptr);
+   imlib_polygon_free(res->ptr);
 }

 void _php_imlib_set_cache_size(int size TSRMLS_DC)
ViewGit