From b8cf53d8a511983faa98b06fcd014f8805f4695a Mon Sep 17 00:00:00 2001 From: Sterling Hughes Date: Fri, 7 Sep 2001 10:29:06 +0000 Subject: [PATCH] get rid of global mess --- ext/mcrypt/mcrypt.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/ext/mcrypt/mcrypt.c b/ext/mcrypt/mcrypt.c index b96122a3e6..e4427ac542 100644 --- a/ext/mcrypt/mcrypt.c +++ b/ext/mcrypt/mcrypt.c @@ -35,6 +35,8 @@ #include "php_globals.h" #include "ext/standard/info.h" +static int le_mcrypt; + function_entry mcrypt_functions[] = { PHP_FE(mcrypt_ecb, NULL) @@ -196,7 +198,7 @@ ZEND_GET_MODULE(mcrypt) if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &mcryptind) == FAILURE) { \ WRONG_PARAM_COUNT \ } \ - ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", MCG(le_h)); + ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt); #define MCRYPT_GET_MODE_DIR_ARGS(DIRECTORY) \ switch (argc) { \ @@ -258,7 +260,7 @@ static PHP_MINIT_FUNCTION(mcrypt) Z_TYPE(mcrypt_module_entry) = type; #endif - MCG(le_h) = zend_register_list_destructors_ex(php_mcrypt_module_dtor, NULL, "mcrypt", module_number); + le_mcrypt = zend_register_list_destructors_ex(php_mcrypt_module_dtor, NULL, "mcrypt", module_number); /* modes for mcrypt_??? routines */ REGISTER_LONG_CONSTANT("MCRYPT_ENCRYPT", 0, CONST_PERSISTENT); @@ -437,7 +439,7 @@ PHP_FUNCTION(mcrypt_module_open) php_error (E_WARNING, "could not open encryption module"); RETURN_FALSE; } else { - ZEND_REGISTER_RESOURCE (return_value, td, MCG(le_h)); + ZEND_REGISTER_RESOURCE (return_value, td, le_mcrypt); } } /* }}} */ @@ -459,7 +461,7 @@ PHP_FUNCTION(mcrypt_generic_init) MCRYPT_CHECK_PARAM_COUNT (3,3) zend_get_parameters_ex(3, &mcryptind, &key, &iv); - ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", MCG(le_h)); + ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt); convert_to_string_ex (key); convert_to_string_ex (iv); @@ -515,7 +517,7 @@ PHP_FUNCTION(mcrypt_generic) MCRYPT_CHECK_PARAM_COUNT (2,2) zend_get_parameters_ex(2, &mcryptind, &data); - ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", MCG(le_h)); + ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt); convert_to_string_ex (data); /* Check blocksize */ @@ -555,7 +557,7 @@ PHP_FUNCTION(mdecrypt_generic) MCRYPT_CHECK_PARAM_COUNT (2,2) zend_get_parameters_ex(2, &mcryptind, &data); - ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", MCG(le_h)); + ZEND_FETCH_RESOURCE (td, MCRYPT, mcryptind, -1, "MCrypt", le_mcrypt); convert_to_string_ex (data); /* Check blocksize */ @@ -630,13 +632,8 @@ PHP_FUNCTION(mcrypt_module_close) MCRYPT_GET_TD_ARG - if (mcrypt_module_close (td) < 0) { - php_error (E_WARNING, "could not close module"); - RETURN_FALSE - } else { - zend_list_delete (Z_LVAL_PP(mcryptind)); - RETURN_TRUE - } + zend_list_delete (Z_LVAL_PP(mcryptind)); + RETURN_TRUE; } -- 2.40.0