helly           Sun Aug 10 21:52:06 2008 UTC

  Modified files:              
    /ZendEngine2        zend.c zend.h zend_builtin_functions.c 
                        zend_builtin_functions.h 
    /php-src/main       main.c 
  Log:
  - Fix memleak, Zend's built-in functions get copied before we copy all
    functions, thus ending up in the name and param definitions copied twice
    because zend_register_funciton already copies them.
  - Also Be able to deallocate Zend's built-in functions and do so when
    appropriate.
  - After unregistering Zend's built-in functions only dl() is left and that
    seems to be fine.
  
  
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.c?r1=1.419&r2=1.420&diff_format=u
Index: ZendEngine2/zend.c
diff -u ZendEngine2/zend.c:1.419 ZendEngine2/zend.c:1.420
--- ZendEngine2/zend.c:1.419    Mon Jul 21 09:36:21 2008
+++ ZendEngine2/zend.c  Sun Aug 10 21:52:05 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.c,v 1.419 2008/07/21 09:36:21 bjori Exp $ */
+/* $Id: zend.c,v 1.420 2008/08/10 21:52:05 helly Exp $ */
 
 #include "zend.h"
 #include "zend_extensions.h"
@@ -1045,7 +1045,7 @@
 
 void zend_init_opcodes_handlers(void);
 
-int zend_startup(zend_utility_functions *utility_functions, char **extensions, 
int start_builtin_functions) /* {{{ */
+int zend_startup(zend_utility_functions *utility_functions, char **extensions) 
/* {{{ */
 {
 #ifdef ZTS
        zend_compiler_globals *compiler_globals;
@@ -1170,10 +1170,6 @@
        zend_init_exception_op(TSRMLS_C);
 #endif
 
-       if (start_builtin_functions) {
-               zend_startup_builtin_functions(TSRMLS_C);
-       }
-
        zend_ini_startup(TSRMLS_C);
 
 #ifdef ZTS
@@ -1209,6 +1205,7 @@
                ucnv_close(UG(runtime_encoding_conv));
                UG(runtime_encoding_conv) = old_runtime_encoding_conv;
        }
+       zend_startup_builtin_functions(TSRMLS_C);
 }
 /* }}} */
 
@@ -1248,6 +1245,7 @@
 #endif
        zend_destroy_rsrc_list(&EG(persistent_list) TSRMLS_CC);
        zend_hash_graceful_reverse_destroy(&module_registry);
+       zend_shutdown_builtin_functions(TSRMLS_C);
 
        zend_hash_destroy(GLOBAL_FUNCTION_TABLE);
        zend_hash_destroy(GLOBAL_CLASS_TABLE);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend.h?r1=1.357&r2=1.358&diff_format=u
Index: ZendEngine2/zend.h
diff -u ZendEngine2/zend.h:1.357 ZendEngine2/zend.h:1.358
--- ZendEngine2/zend.h:1.357    Fri Aug  8 17:10:49 2008
+++ ZendEngine2/zend.h  Sun Aug 10 21:52:05 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend.h,v 1.357 2008/08/08 17:10:49 helly Exp $ */
+/* $Id: zend.h,v 1.358 2008/08/10 21:52:05 helly Exp $ */
 
 #ifndef ZEND_H
 #define ZEND_H
@@ -572,7 +572,7 @@
 /* default engine string type */
 #define ZEND_STR_TYPE (UG(unicode) ? IS_UNICODE : IS_STRING)
 
-int zend_startup(zend_utility_functions *utility_functions, char **extensions, 
int start_builtin_functions);
+int zend_startup(zend_utility_functions *utility_functions, char **extensions);
 void zend_shutdown(TSRMLS_D);
 void zend_register_standard_ini_entries(TSRMLS_D);
 void zend_post_startup(TSRMLS_D);
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.c?r1=1.381&r2=1.382&diff_format=u
Index: ZendEngine2/zend_builtin_functions.c
diff -u ZendEngine2/zend_builtin_functions.c:1.381 
ZendEngine2/zend_builtin_functions.c:1.382
--- ZendEngine2/zend_builtin_functions.c:1.381  Sat Aug  2 04:40:43 2008
+++ ZendEngine2/zend_builtin_functions.c        Sun Aug 10 21:52:05 2008
@@ -17,7 +17,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.c,v 1.381 2008/08/02 04:40:43 felipe Exp $ */
+/* $Id: zend_builtin_functions.c,v 1.382 2008/08/10 21:52:05 helly Exp $ */
 
 #include "zend.h"
 #include "zend_API.h"
@@ -416,6 +416,12 @@
 }
 /* }}} */
 
+void zend_shutdown_builtin_functions(TSRMLS_D) /* {{{ */
+{
+       zend_unregister_functions(builtin_functions, -1, NULL TSRMLS_CC);
+}
+/* }}} */
+
 /* {{{ proto string zend_version(void) U
    Get the version of the Zend Engine */
 ZEND_FUNCTION(zend_version)
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_builtin_functions.h?r1=1.21&r2=1.22&diff_format=u
Index: ZendEngine2/zend_builtin_functions.h
diff -u ZendEngine2/zend_builtin_functions.h:1.21 
ZendEngine2/zend_builtin_functions.h:1.22
--- ZendEngine2/zend_builtin_functions.h:1.21   Mon Dec 31 07:12:06 2007
+++ ZendEngine2/zend_builtin_functions.h        Sun Aug 10 21:52:05 2008
@@ -17,12 +17,13 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_builtin_functions.h,v 1.21 2007/12/31 07:12:06 sebastian Exp $ */
+/* $Id: zend_builtin_functions.h,v 1.22 2008/08/10 21:52:05 helly Exp $ */
 
 #ifndef ZEND_BUILTIN_FUNCTIONS_H
 #define ZEND_BUILTIN_FUNCTIONS_H
 
 int zend_startup_builtin_functions(TSRMLS_D);
+int zend_shutdown_builtin_functions(TSRMLS_D);
 
 BEGIN_EXTERN_C()
 ZEND_API void zend_fetch_debug_backtrace(zval *return_value, int skip_last, 
int provide_object TSRMLS_DC);
http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.776&r2=1.777&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.776 php-src/main/main.c:1.777
--- php-src/main/main.c:1.776   Fri Aug  8 17:10:49 2008
+++ php-src/main/main.c Sun Aug 10 21:52:05 2008
@@ -18,7 +18,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: main.c,v 1.776 2008/08/08 17:10:49 helly Exp $ */
+/* $Id: main.c,v 1.777 2008/08/10 21:52:05 helly Exp $ */
 
 /* {{{ includes
  */
@@ -1838,7 +1838,7 @@
        zuf.vspprintf_function = vspprintf;
        zuf.getenv_function = sapi_getenv;
        zuf.resolve_path_function = php_resolve_path_for_zend;
-       zend_startup(&zuf, NULL, 1);
+       zend_startup(&zuf, NULL);
 
 #ifdef ZTS
        executor_globals = ts_resource(executor_globals_id);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to