@@ -200,7 +200,7 @@ PHP_FUNCTION(xhprof_sample_disable)
200200 /* else null is returned */
201201}
202202
203- PHP_GINIT_FUNCTION ( xhprof )
203+ static void php_xhprof_init_globals ( zend_xhprof_globals * xhprof_globals )
204204{
205205 xhprof_globals -> enabled = 0 ;
206206 xhprof_globals -> ever_enabled = 0 ;
@@ -211,6 +211,21 @@ PHP_GINIT_FUNCTION(xhprof)
211211 xhprof_globals -> ignored_functions = NULL ;
212212 xhprof_globals -> sampling_interval = XHPROF_DEFAULT_SAMPLING_INTERVAL ;
213213 xhprof_globals -> sampling_depth = INT_MAX ;
214+
215+ ZVAL_UNDEF (& xhprof_globals -> stats_count );
216+
217+ /* no free hp_entry_t structures to start with */
218+ xhprof_globals -> entry_free_list = NULL ;
219+
220+ int i ;
221+
222+ for (i = 0 ; i < 256 ; i ++ ) {
223+ xhprof_globals -> func_hash_counters [i ] = 0 ;
224+ }
225+
226+ if (xhprof_globals -> sampling_interval < XHPROF_MINIMAL_SAMPLING_INTERVAL ) {
227+ xhprof_globals -> sampling_interval = XHPROF_MINIMAL_SAMPLING_INTERVAL ;
228+ }
214229}
215230
216231/**
@@ -220,24 +235,12 @@ PHP_GINIT_FUNCTION(xhprof)
220235 */
221236PHP_MINIT_FUNCTION (xhprof )
222237{
223- int i ;
238+ ZEND_INIT_MODULE_GLOBALS ( xhprof , php_xhprof_init_globals , NULL ) ;
224239
225240 REGISTER_INI_ENTRIES ();
226241
227242 hp_register_constants (INIT_FUNC_ARGS_PASSTHRU );
228243
229- ZVAL_UNDEF (& XHPROF_G (stats_count ));
230-
231- /* no free hp_entry_t structures to start with */
232- XHPROF_G (entry_free_list ) = NULL ;
233-
234- for (i = 0 ; i < 256 ; i ++ ) {
235- XHPROF_G (func_hash_counters [i ]) = 0 ;
236- }
237- if (XHPROF_G (sampling_interval ) < XHPROF_MINIMAL_SAMPLING_INTERVAL ) {
238- XHPROF_G (sampling_interval ) = XHPROF_MINIMAL_SAMPLING_INTERVAL ;
239- }
240-
241244 /* Replace zend_compile with our proxy */
242245 _zend_compile_file = zend_compile_file ;
243246 zend_compile_file = hp_compile_file ;
0 commit comments