40
40
41
41
#define PREG_REPLACE_EVAL (1<<0)
42
42
43
- #ifdef ZTS
44
- int pcre_globals_id ;
45
- #else
46
- php_pcre_globals pcre_globals ;
47
- #endif
43
+
44
+ ZEND_DECLARE_MODULE_GLOBALS (pcre )
48
45
49
46
50
47
static void * php_pcre_malloc (size_t size )
@@ -69,16 +66,15 @@ static void php_free_pcre_cache(void *data)
69
66
}
70
67
71
68
72
- #ifdef ZTS
73
- static void php_pcre_init_globals (php_pcre_globals * pcre_globals TSRMLS_DC )
69
+ static void php_pcre_init_globals (zend_pcre_globals * pcre_globals TSRMLS_DC )
74
70
{
75
- zend_hash_init (& PCRE_G ( pcre_cache ) , 0 , NULL , php_free_pcre_cache , 1 );
71
+ zend_hash_init (& pcre_globals -> pcre_cache , 0 , NULL , php_free_pcre_cache , 1 );
76
72
}
77
73
78
-
79
- static void php_pcre_shutdown_globals (php_pcre_globals * pcre_globals TSRMLS_DC )
74
+ #ifdef ZTS
75
+ static void php_pcre_shutdown_globals (zend_pcre_globals * pcre_globals TSRMLS_DC )
80
76
{
81
- zend_hash_destroy (& PCRE_G ( pcre_cache ) );
77
+ zend_hash_destroy (& pcre_globals -> pcre_cache );
82
78
}
83
79
#endif
84
80
@@ -96,15 +92,7 @@ PHP_MINFO_FUNCTION(pcre)
96
92
/* {{{ PHP_MINIT_FUNCTION(pcre) */
97
93
static PHP_MINIT_FUNCTION (pcre )
98
94
{
99
- #ifdef ZTS
100
- ts_allocate_id (
101
- & pcre_globals_id ,
102
- sizeof (php_pcre_globals ),
103
- (ts_allocate_ctor ) php_pcre_init_globals ,
104
- (ts_allocate_dtor ) php_pcre_shutdown_globals );
105
- #else
106
- zend_hash_init (& PCRE_G (pcre_cache ), 0 , NULL , php_free_pcre_cache , 1 );
107
- #endif
95
+ ZEND_INIT_MODULE_GLOBALS (pcre , php_pcre_init_globals , php_pcre_shutdown_globals );
108
96
109
97
REGISTER_LONG_CONSTANT ("PREG_PATTERN_ORDER" , PREG_PATTERN_ORDER , CONST_CS | CONST_PERSISTENT );
110
98
REGISTER_LONG_CONSTANT ("PREG_SET_ORDER" , PREG_SET_ORDER , CONST_CS | CONST_PERSISTENT );
@@ -117,11 +105,6 @@ static PHP_MINIT_FUNCTION(pcre)
117
105
/* {{{ PHP_MSHUTDOWN_FUNCTION(pcre) */
118
106
static PHP_MSHUTDOWN_FUNCTION (pcre )
119
107
{
120
- #ifndef ZTS
121
- zend_hash_destroy (& PCRE_G (pcre_cache ));
122
- #else
123
- ts_free_id (pcre_globals_id );
124
- #endif
125
108
return SUCCESS ;
126
109
}
127
110
/* }}} */
@@ -158,7 +141,7 @@ static pcre* pcre_get_compiled_regex(char *regex, pcre_extra *extra, int *preg_o
158
141
#endif
159
142
pcre_cache_entry * pce ;
160
143
pcre_cache_entry new_entry ;
161
- PCRE_LS_FETCH ();
144
+ TSRMLS_FETCH ();
162
145
163
146
/* Try to lookup the cached regex entry, and if successful, just pass
164
147
back the compiled pattern, otherwise go on and compile it. */
0 commit comments