dmitry Mon Jul 17 07:20:12 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/main main.c Log: Fixed memory leaks in ZTS mode. http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.640.2.23.2.9&r2=1.640.2.23.2.10&diff_format=u Index: php-src/main/main.c diff -u php-src/main/main.c:1.640.2.23.2.9 php-src/main/main.c:1.640.2.23.2.10 --- php-src/main/main.c:1.640.2.23.2.9 Fri Jun 16 14:09:00 2006 +++ php-src/main/main.c Mon Jul 17 07:20:12 2006 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.640.2.23.2.9 2006/06/16 14:09:00 rasmus Exp $ */ +/* $Id: main.c,v 1.640.2.23.2.10 2006/07/17 07:20:12 dmitry Exp $ */ /* {{{ includes */ @@ -1350,6 +1350,25 @@ /* }}} */ #endif +/* {{{ core_globals_dtor + */ +static void core_globals_dtor(php_core_globals *core_globals TSRMLS_DC) +{ + if (core_globals->last_error_message) { + free(core_globals->last_error_message); + } + if (core_globals->last_error_file) { + free(core_globals->last_error_file); + } + if (core_globals->disable_functions) { + free(core_globals->disable_functions); + } + if (core_globals->disable_classes) { + free(core_globals->disable_classes); + } +} +/* }}} */ + /* {{{ php_register_extensions */ int php_register_extensions(zend_module_entry **ptr, int count TSRMLS_DC) @@ -1436,7 +1455,7 @@ #ifdef ZTS executor_globals = ts_resource(executor_globals_id); - ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, NULL); + ts_allocate_id(&core_globals_id, sizeof(php_core_globals), (ts_allocate_ctor) core_globals_ctor, (ts_allocate_dtor) core_globals_dtor); core_globals = ts_resource(core_globals_id); #ifdef PHP_WIN32 ts_allocate_id(&php_win32_core_globals_id, sizeof(php_win32_core_globals), (ts_allocate_ctor) php_win32_core_globals_ctor, NULL); @@ -1639,23 +1658,13 @@ #ifndef ZTS zend_ini_shutdown(TSRMLS_C); shutdown_memory_manager(CG(unclean_shutdown), 1 TSRMLS_CC); + core_globals_dtor(&core_globals TSRMLS_CC); #else zend_ini_global_shutdown(TSRMLS_C); + ts_free_id(core_globals_id); #endif module_initialized = 0; - if (PG(last_error_message)) { - free(PG(last_error_message)); - } - if (PG(last_error_file)) { - free(PG(last_error_file)); - } - if (PG(disable_functions)) { - free(PG(disable_functions)); - } - if (PG(disable_classes)) { - free(PG(disable_classes)); - } } /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php