]> granicus.if.org Git - php/commitdiff
Simplify
authorMarcus Boerger <helly@php.net>
Sat, 27 Dec 2003 20:33:14 +0000 (20:33 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 27 Dec 2003 20:33:14 +0000 (20:33 +0000)
Zend/zend_objects.c

index 67e943428acec1bdf2abb3e106426e3d87bf0626..172ca0f8feb655fc61155db93bab75c332ad317f 100644 (file)
@@ -23,6 +23,7 @@
 #include "zend_globals.h"
 #include "zend_variables.h"
 #include "zend_API.h"
+#include "zend_interfaces.h"
 
 static inline void zend_nuke_object(zend_object *object TSRMLS_DC)
 {
@@ -36,10 +37,7 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
        zend_function *destructor = object->ce->destructor;
 
        if (destructor) {
-               zval *obj;
-               zval *destructor_func_name;
-               zval *retval_ptr;
-               HashTable symbol_table;
+               zval zobj, *obj = &zobj;
                
                if (destructor->op_array.fn_flags & (ZEND_ACC_PRIVATE|ZEND_ACC_PROTECTED)) {
                        if (destructor->op_array.fn_flags & ZEND_ACC_PRIVATE) {
@@ -73,28 +71,12 @@ ZEND_API void zend_objects_destroy_object(zend_object *object, zend_object_handl
                        }
                }
 
-               MAKE_STD_ZVAL(obj);
-               obj->type = IS_OBJECT;
-               obj->value.obj.handle = handle;
-               obj->value.obj.handlers = &std_object_handlers;
-               zval_copy_ctor(obj);
-
-               ZEND_INIT_SYMTABLE(&symbol_table);
-               
-               /* FIXME: Optimize this so that we use the old_object->ce->destructor function pointer instead of the name */
-               MAKE_STD_ZVAL(destructor_func_name);
-               destructor_func_name->type = IS_STRING;
-               destructor_func_name->value.str.val = estrndup("__destruct", sizeof("__destruct")-1);
-               destructor_func_name->value.str.len = sizeof("__destruct")-1;
+               zobj.type = IS_OBJECT;
+               zobj.value.obj.handle = handle;
+               zobj.value.obj.handlers = &std_object_handlers;
+               INIT_PZVAL(obj);
 
-               call_user_function_ex(NULL, &obj, destructor_func_name, &retval_ptr, 0, NULL, 0, &symbol_table TSRMLS_CC);
-
-               zend_hash_destroy(&symbol_table);
-               zval_ptr_dtor(&obj);
-               zval_ptr_dtor(&destructor_func_name);
-               if (retval_ptr) {
-                       zval_ptr_dtor(&retval_ptr);
-               }
+               zend_call_method_with_0_params(&obj, object->ce, NULL, "__destruct", NULL);
        }
        zend_nuke_object(object TSRMLS_CC);
 }