From 5903f9f85b1329efb1d0c6e427dbcff567540846 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 31 Oct 2017 17:16:36 +0100 Subject: Minor factorization --- src/snuffleupagus.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c index 7db6c93..e453587 100644 --- a/src/snuffleupagus.c +++ b/src/snuffleupagus.c @@ -52,15 +52,6 @@ ZEND_DLEXPORT zend_extension zend_extension_entry = { NULL, /* op_array_dtor_func_t */ STANDARD_ZEND_EXTENSION_PROPERTIES}; -/* Uncomment this function if you have INI entries -static void php_snuffleupagus_init_globals(zend_snuffleupagus_globals -*snuffleupagus_globals) -{ - snuffleupagus_globals->global_value = 0; - snuffleupagus_globals->global_string = NULL; -} -*/ - PHP_GINIT_FUNCTION(snuffleupagus) { #define SP_INIT(F) F = pecalloc(sizeof(*F), 1, 1); #define SP_INIT_HT(F) \ @@ -119,20 +110,21 @@ PHP_MSHUTDOWN_FUNCTION(snuffleupagus) { pefree(SNUFFLEUPAGUS_G(config.config_upload_validation), 1); pefree(SNUFFLEUPAGUS_G(config.config_cookie_encryption), 1); - sp_node_t* disabled_functions = SNUFFLEUPAGUS_G(config.config_disabled_functions->disabled_functions); - sp_node_t* disabled_functions_ret = SNUFFLEUPAGUS_G(config.config_disabled_functions_ret->disabled_functions); - sp_node_t* disabled_constructs = SNUFFLEUPAGUS_G(config.config_disabled_constructs->construct_include); +#define FREE_LST(L) \ + do { \ + sp_node_t* _n = SNUFFLEUPAGUS_G(L); \ + sp_disabled_function_list_free(_n); \ + sp_list_free(_n); \ + } while(0) + + FREE_LST(config.config_disabled_functions->disabled_functions); + FREE_LST(config.config_disabled_functions_ret->disabled_functions); + FREE_LST(config.config_disabled_constructs->construct_include); - // Free the list of disabled functions for each `sp_disabled_function` instance - sp_disabled_function_list_free(disabled_functions); - sp_disabled_function_list_free(disabled_functions_ret); - sp_disabled_function_list_free(disabled_constructs); +#undef FREE_LST - sp_list_free(disabled_functions); pefree(SNUFFLEUPAGUS_G(config.config_disabled_functions), 1); - sp_list_free(disabled_functions_ret); pefree(SNUFFLEUPAGUS_G(config.config_disabled_functions_ret), 1); - sp_list_free(disabled_constructs); pefree(SNUFFLEUPAGUS_G(config.config_disabled_constructs), 1); UNREGISTER_INI_ENTRIES(); -- cgit v1.3