]> granicus.if.org Git - php/commitdiff
Fix bug #17570.
authorAndrei Zmievski <andrei@php.net>
Wed, 25 Sep 2002 14:02:34 +0000 (14:02 +0000)
committerAndrei Zmievski <andrei@php.net>
Wed, 25 Sep 2002 14:02:34 +0000 (14:02 +0000)
ext/ereg/ereg.c
ext/ereg/php_ereg.h
ext/standard/reg.c
ext/standard/reg.h

index 6d67f17e40db9d1d425bf8c973a7e837995a3e0f..b30d0d527b63a892c5245a7f7c479341d3fa957b 100644 (file)
 #include "reg.h"
 #include "ext/standard/info.h"
 
-#ifdef ZTS
-int reg_globals_id;
-#else
-static php_reg_globals reg_globals;
-#endif
+ZEND_DECLARE_MODULE_GLOBALS(reg)
 
 typedef struct {
        regex_t preg;
@@ -75,25 +71,28 @@ static void _free_reg_cache(reg_cache *rc)
 #undef regcomp
 #define regcomp(a, b, c) _php_regcomp(a, b, c)
        
-static void php_reg_init_globals(php_reg_globals *reg_globals TSRMLS_DC)
+static void php_reg_init_globals(zend_reg_globals *reg_globals TSRMLS_DC)
 {
        zend_hash_init(&reg_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_reg_cache, 1);
 }
 
-PHP_MINIT_FUNCTION(regex)
+static void php_reg_destroy_globals(zend_reg_globals *reg_globals TSRMLS_DC)
 {
-#ifdef ZTS
-       ts_allocate_id(&reg_globals_id, sizeof(php_reg_globals), (ts_allocate_ctor) php_reg_init_globals, NULL);
-#else
-       php_reg_init_globals(&reg_globals TSRMLS_CC);
-#endif
+       zend_hash_destroy(&reg_globals->ht_rc);
+}
 
+PHP_MINIT_FUNCTION(regex)
+{
+       ZEND_INIT_MODULE_GLOBALS(reg, php_reg_init_globals, php_reg_destroy_globals);
        return SUCCESS;
 }
 
 PHP_MSHUTDOWN_FUNCTION(regex)
 {
-       zend_hash_destroy(&REG(ht_rc));
+#ifndef ZTS
+       php_reg_destroy_globals(&reg_globals TSRMLS_CC);
+#endif
+
        return SUCCESS;
 }
 
index 38c99837e01204f8559b6f632d31724d41979876..92947eaa926e325031c42a4e589f4a5cbb7d252c 100644 (file)
@@ -32,9 +32,9 @@ PHP_FUNCTION(split);
 PHP_FUNCTION(spliti);
 PHPAPI PHP_FUNCTION(sql_regcase);
 
-typedef struct {
+ZEND_BEGIN_MODULE_GLOBALS(reg)
        HashTable ht_rc;
-} php_reg_globals;
+ZEND_END_MODULE_GLOBALS(reg)
 
 PHP_MINIT_FUNCTION(regex);
 PHP_MSHUTDOWN_FUNCTION(regex);
index 6d67f17e40db9d1d425bf8c973a7e837995a3e0f..b30d0d527b63a892c5245a7f7c479341d3fa957b 100644 (file)
 #include "reg.h"
 #include "ext/standard/info.h"
 
-#ifdef ZTS
-int reg_globals_id;
-#else
-static php_reg_globals reg_globals;
-#endif
+ZEND_DECLARE_MODULE_GLOBALS(reg)
 
 typedef struct {
        regex_t preg;
@@ -75,25 +71,28 @@ static void _free_reg_cache(reg_cache *rc)
 #undef regcomp
 #define regcomp(a, b, c) _php_regcomp(a, b, c)
        
-static void php_reg_init_globals(php_reg_globals *reg_globals TSRMLS_DC)
+static void php_reg_init_globals(zend_reg_globals *reg_globals TSRMLS_DC)
 {
        zend_hash_init(&reg_globals->ht_rc, 0, NULL, (void (*)(void *)) _free_reg_cache, 1);
 }
 
-PHP_MINIT_FUNCTION(regex)
+static void php_reg_destroy_globals(zend_reg_globals *reg_globals TSRMLS_DC)
 {
-#ifdef ZTS
-       ts_allocate_id(&reg_globals_id, sizeof(php_reg_globals), (ts_allocate_ctor) php_reg_init_globals, NULL);
-#else
-       php_reg_init_globals(&reg_globals TSRMLS_CC);
-#endif
+       zend_hash_destroy(&reg_globals->ht_rc);
+}
 
+PHP_MINIT_FUNCTION(regex)
+{
+       ZEND_INIT_MODULE_GLOBALS(reg, php_reg_init_globals, php_reg_destroy_globals);
        return SUCCESS;
 }
 
 PHP_MSHUTDOWN_FUNCTION(regex)
 {
-       zend_hash_destroy(&REG(ht_rc));
+#ifndef ZTS
+       php_reg_destroy_globals(&reg_globals TSRMLS_CC);
+#endif
+
        return SUCCESS;
 }
 
index 38c99837e01204f8559b6f632d31724d41979876..92947eaa926e325031c42a4e589f4a5cbb7d252c 100644 (file)
@@ -32,9 +32,9 @@ PHP_FUNCTION(split);
 PHP_FUNCTION(spliti);
 PHPAPI PHP_FUNCTION(sql_regcase);
 
-typedef struct {
+ZEND_BEGIN_MODULE_GLOBALS(reg)
        HashTable ht_rc;
-} php_reg_globals;
+ZEND_END_MODULE_GLOBALS(reg)
 
 PHP_MINIT_FUNCTION(regex);
 PHP_MSHUTDOWN_FUNCTION(regex);