From: Zeev Suraski Date: Wed, 4 Feb 2004 11:14:47 +0000 (+0000) Subject: - Update with new destructor code X-Git-Tag: php-5.0.0b4RC1~153 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8424be849f7523f589ff673b860bad4126b4fa63;p=php - Update with new destructor code --- diff --git a/ext/com_dotnet/com_handlers.c b/ext/com_dotnet/com_handlers.c index 321f478903..8d548e37b1 100644 --- a/ext/com_dotnet/com_handlers.c +++ b/ext/com_dotnet/com_handlers.c @@ -554,7 +554,7 @@ void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable TSR } } -void php_com_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) +void php_com_object_free_storage(void *object TSRMLS_DC) { php_com_dotnet_object *obj = (php_com_dotnet_object*)object; @@ -616,7 +616,8 @@ zend_object_value php_com_object_new(zend_class_entry *ce TSRMLS_DC) obj->code_page = CP_ACP; obj->ce = ce; - retval.handle = zend_objects_store_put(obj, php_com_object_dtor, php_com_object_clone TSRMLS_CC); + + retval.handle = zend_objects_store_put(obj, NULL, php_com_object_free_storage, php_com_object_clone TSRMLS_CC); retval.handlers = &php_com_object_handlers; return retval; diff --git a/ext/com_dotnet/com_misc.c b/ext/com_dotnet/com_misc.c index 9c85e1d7ca..f4e54cd722 100644 --- a/ext/com_dotnet/com_misc.c +++ b/ext/com_dotnet/com_misc.c @@ -60,7 +60,7 @@ PHPAPI void php_com_wrap_dispatch(zval *z, IDispatch *disp, IDispatch_GetTypeInfo(V_DISPATCH(&obj->v), 0, LANG_NEUTRAL, &obj->typeinfo); Z_TYPE_P(z) = IS_OBJECT; - z->value.obj.handle = zend_objects_store_put(obj, php_com_object_dtor, php_com_object_clone TSRMLS_CC); + z->value.obj.handle = zend_objects_store_put(obj, NULL, php_com_object_free_storage, php_com_object_clone TSRMLS_CC); z->value.obj.handlers = &php_com_object_handlers; } @@ -83,7 +83,7 @@ PHPAPI void php_com_wrap_variant(zval *z, VARIANT *v, Z_TYPE_P(z) = IS_OBJECT; - z->value.obj.handle = zend_objects_store_put(obj, php_com_object_dtor, php_com_object_clone TSRMLS_CC); + z->value.obj.handle = zend_objects_store_put(obj, NULL, php_com_object_free_storage, php_com_object_clone TSRMLS_CC); z->value.obj.handlers = &php_com_object_handlers; } diff --git a/ext/com_dotnet/com_saproxy.c b/ext/com_dotnet/com_saproxy.c index fb8c28a3f4..a8485b688c 100644 --- a/ext/com_dotnet/com_saproxy.c +++ b/ext/com_dotnet/com_saproxy.c @@ -261,7 +261,7 @@ zend_object_handlers php_com_saproxy_handlers = { saproxy_object_cast }; -static void saproxy_dtor(void *object, zend_object_handle handle TSRMLS_DC) +static void saproxy_free_storage(void *object TSRMLS_DC) { php_com_saproxy *proxy = (php_com_saproxy *)object; @@ -313,7 +313,7 @@ int php_com_saproxy_create(zval *com_object, zval *proxy_out, long index TSRMLS_ proxy->indices[proxy->dimensions-1] = index; Z_TYPE_P(proxy_out) = IS_OBJECT; - Z_OBJ_HANDLE_P(proxy_out) = zend_objects_store_put(proxy, saproxy_dtor, saproxy_clone TSRMLS_CC); + Z_OBJ_HANDLE_P(proxy_out) = zend_objects_store_put(proxy, NULL, saproxy_free_storage, saproxy_clone TSRMLS_CC); Z_OBJ_HT_P(proxy_out) = &php_com_saproxy_handlers; return 1; diff --git a/ext/com_dotnet/php_com_dotnet_internal.h b/ext/com_dotnet/php_com_dotnet_internal.h index 762972ec43..2ff1d16abf 100644 --- a/ext/com_dotnet/php_com_dotnet_internal.h +++ b/ext/com_dotnet/php_com_dotnet_internal.h @@ -77,7 +77,7 @@ zend_class_entry *php_com_variant_class_entry, *php_com_exception_class_entry, * /* com_handlers.c */ zend_object_value php_com_object_new(zend_class_entry *ce TSRMLS_DC); void php_com_object_clone(void *object, void **clone_ptr TSRMLS_DC); -void php_com_object_dtor(void *object, zend_object_handle handle TSRMLS_DC); +void php_com_object_free_storage(void *object TSRMLS_DC); zend_object_handlers php_com_object_handlers; void php_com_object_enable_event_sink(php_com_dotnet_object *obj, int enable TSRMLS_DC); diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c index 770a89696f..7d38105a9e 100644 --- a/ext/dom/php_dom.c +++ b/ext/dom/php_dom.c @@ -728,8 +728,8 @@ void dom_objects_clone(void *object, void **object_clone TSRMLS_DC) /* }}} */ #if defined(LIBXML_XPATH_ENABLED) -/* {{{ dom_xpath_objects_dtor */ -void dom_xpath_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) +/* {{{ dom_xpath_objects_free_storage */ +void dom_xpath_objects_free_storage(void *object TSRMLS_DC) { dom_object *intern = (dom_object *)object; @@ -747,8 +747,8 @@ void dom_xpath_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) /* }}} */ #endif -/* {{{ dom_objects_dtor */ -void dom_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) +/* {{{ dom_objects_free_storage */ +void dom_objects_free_storage(void *object TSRMLS_DC) { dom_object *intern = (dom_object *)object; int retcount; @@ -830,7 +830,7 @@ zend_object_value dom_objects_new(zend_class_entry *class_type TSRMLS_DC) intern = dom_objects_set_class(class_type TSRMLS_CC); - retval.handle = zend_objects_store_put(intern, dom_objects_dtor, dom_objects_clone TSRMLS_CC); + retval.handle = zend_objects_store_put(intern, NULL, dom_objects_free_storage, dom_objects_clone TSRMLS_CC); intern->handle = retval.handle; retval.handlers = &dom_object_handlers; @@ -847,7 +847,7 @@ zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC) intern = dom_objects_set_class(class_type TSRMLS_CC); - retval.handle = zend_objects_store_put(intern, dom_xpath_objects_dtor, dom_objects_clone TSRMLS_CC); + retval.handle = zend_objects_store_put(intern, NULL, dom_xpath_objects_free_storage, dom_objects_clone TSRMLS_CC); intern->handle = retval.handle; retval.handlers = &dom_object_handlers; @@ -856,7 +856,7 @@ zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC) /* }}} */ #endif -void dom_nnodemap_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) +void dom_nnodemap_objects_free_storage(void *object TSRMLS_DC) { dom_nnodemap_object *objmap; zval *baseobj; @@ -900,7 +900,7 @@ zend_object_value dom_nnodemap_objects_new(zend_class_entry *class_type TSRMLS_D objmap->local = NULL; objmap->ns = NULL; - retval.handle = zend_objects_store_put(intern, dom_nnodemap_objects_dtor, dom_objects_clone TSRMLS_CC); + retval.handle = zend_objects_store_put(intern, NULL, dom_nnodemap_objects_free_storage, dom_objects_clone TSRMLS_CC); intern->handle = retval.handle; retval.handlers = &dom_object_handlers; diff --git a/ext/mysqli/mysqli.c b/ext/mysqli/mysqli.c index a55d2bb229..c0ce4303b3 100644 --- a/ext/mysqli/mysqli.c +++ b/ext/mysqli/mysqli.c @@ -101,9 +101,9 @@ void php_clear_stmt_bind(STMT *stmt) } /* }}} */ -/* {{{ mysqli_objects_dtor +/* {{{ mysqli_objects_free_storage */ -static void mysqli_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) +static void mysqli_objects_free_storage(void *object TSRMLS_DC) { mysqli_object *intern = (mysqli_object *)object; MYSQLI_RESOURCE *my_res = (MYSQLI_RESOURCE *)intern->ptr; @@ -276,7 +276,7 @@ PHP_MYSQLI_EXPORT(zend_object_value) mysqli_objects_new(zend_class_entry *class_ zend_hash_copy(intern->zo.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - retval.handle = zend_objects_store_put(intern, mysqli_objects_dtor, mysqli_objects_clone TSRMLS_CC); + retval.handle = zend_objects_store_put(intern, NULL, mysqli_objects_free_storage, mysqli_objects_clone TSRMLS_CC); retval.handlers = &mysqli_object_handlers; return retval; diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 936aaf7fe8..ebf7b0e61a 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -114,16 +114,16 @@ static xmlNodePtr php_sxe_get_first_node(php_sxe_object *sxe, xmlNodePtr node TS /* {{{ match_ns() */ -static inline int +static inline int match_ns(php_sxe_object *sxe, xmlNodePtr node, xmlChar *name) { if (name == NULL && (node->ns == NULL || node->ns->prefix == NULL)) { return 1; } - + if (node->ns && !xmlStrcmp(node->ns->href, name)) { return 1; - } + } return 0; } @@ -392,7 +392,7 @@ static void sxe_prop_dim_write(zval *object, zval *member, zval *value, zend_boo newnode = node; ++counter; } - + next_iter: node = node->next; } @@ -459,7 +459,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend xmlNodePtr node; xmlAttrPtr attr = NULL; int exists = 0; - + sxe = php_sxe_fetch_object(object TSRMLS_CC); name = Z_STRVAL_P(member); @@ -488,7 +488,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend exists = 1; break; } - + attr = attr->next; } } @@ -568,9 +568,9 @@ static void sxe_prop_dim_delete(zval *object, zval *member, zend_bool elements, node = node->children; while (node) { nnext = node->next; - + SKIP_TEXT(node); - + if (!xmlStrcmp(node->name, Z_STRVAL_P(member))) { xmlUnlinkNode(node); php_libxml_node_free_resource(node TSRMLS_CC); @@ -613,7 +613,7 @@ _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value TSRM xmlChar *contents; MAKE_STD_ZVAL(*value); - + if (node->children && node->children->type == XML_TEXT_NODE && !xmlIsBlankNode(node->children)) { contents = xmlNodeListGetString(node->doc, node->children, 1); if (contents) { @@ -676,7 +676,7 @@ sxe_properties_get(zval *object TSRMLS_DC) goto next_iter; } } - + name = (char *) node->name; if (!name) { goto next_iter; @@ -685,7 +685,7 @@ sxe_properties_get(zval *object TSRMLS_DC) } _get_base_node_value(sxe, node, &value TSRMLS_CC); - + h = zend_hash_func(name, namelen); if (zend_hash_quick_find(rv, name, namelen, h, (void **) &data_ptr) == SUCCESS) { if (Z_TYPE_PP(data_ptr) == IS_ARRAY) { @@ -738,7 +738,7 @@ sxe_objects_compare(zval *object1, zval *object2 TSRMLS_DC) /* }}} */ /* {{{ xpath() - */ + */ SXE_METHOD(xpath) { php_sxe_object *sxe; @@ -813,7 +813,7 @@ SXE_METHOD(xpath) add_next_index_zval(return_value, value); } } - + xmlXPathFreeObject(retval); } /* }}} */ @@ -838,10 +838,10 @@ SXE_METHOD(asXML) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &filename, &filename_len) == FAILURE) { RETURN_FALSE; } - + sxe = php_sxe_fetch_object(getThis() TSRMLS_CC); GET_NODE(sxe, node); - + if (node) { if (XML_DOCUMENT_NODE == node->parent->type) { xmlSaveFile(filename, (xmlDocPtr) sxe->document->ptr); @@ -850,7 +850,7 @@ SXE_METHOD(asXML) if (outbuf == NULL) { RETURN_FALSE; - } + } xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 1, NULL); xmlOutputBufferClose(outbuf); @@ -873,11 +873,11 @@ SXE_METHOD(asXML) if (outbuf == NULL) { RETURN_FALSE; - } + } xmlNodeDumpOutput(outbuf, (xmlDocPtr) sxe->document->ptr, node, 0, 1, ((xmlDocPtr) sxe->document->ptr)->encoding); xmlOutputBufferFlush(outbuf); - strval = xmlStrndup(outbuf->buffer->content, outbuf->buffer->use); + strval = xmlStrndup(outbuf->buffer->content, outbuf->buffer->use); xmlOutputBufferClose(outbuf); } @@ -1062,9 +1062,18 @@ sxe_object_clone(void *object, void **clone_ptr TSRMLS_DC) } /* }}} */ -/* {{{ sxe_object_dtor() +/* {{{ _free_ns_entry() + */ +static void +_free_ns_entry(void *p, xmlChar *data) +{ + xmlFree(p); +} +/* }}} */ + +/* {{{ sxe_object_free_storage() */ -static void sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) +static void sxe_object_free_storage(void *object TSRMLS_DC) { php_sxe_object *sxe; @@ -1089,17 +1098,17 @@ static void sxe_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) if (sxe->xpath) { xmlXPathFreeContext(sxe->xpath); } - + if (sxe->properties) { zend_hash_destroy(sxe->properties); FREE_HASHTABLE(sxe->properties); } - + efree(object); } /* }}} */ -/* {{{ php_sxe_object_new() +/* {{{ php_sxe_object_new() */ static php_sxe_object* php_sxe_object_new(zend_class_entry *ce TSRMLS_DC) { @@ -1126,7 +1135,7 @@ php_sxe_register_object(php_sxe_object *intern TSRMLS_DC) { zend_object_value rv; - rv.handle = zend_objects_store_put(intern, sxe_object_dtor, sxe_object_clone TSRMLS_CC); + rv.handle = zend_objects_store_put(intern, NULL, sxe_object_free_storage, sxe_object_clone TSRMLS_CC); rv.handlers = (zend_object_handlers *) &sxe_object_handlers; return rv; @@ -1296,7 +1305,7 @@ ZEND_API void php_sxe_reset_iterator(php_sxe_object *sxe TSRMLS_DC) while (node) { SKIP_TEXT(node); if (sxe->iter.type != SXE_ITER_ATTRLIST && node->type == XML_ELEMENT_NODE) { - if (sxe->iter.type == SXE_ITER_ELEMENT) { + if (sxe->iter.type == SXE_ITER_ELEMENT) { if (!xmlStrcmp(node->name, sxe->iter.name) && match_ns(sxe, node, prefix)) { break; } @@ -1330,7 +1339,7 @@ zend_object_iterator *php_sxe_get_iterator(zend_class_entry *ce, zval *object TS iterator->intern.data = (void*)object; iterator->intern.funcs = &php_sxe_iterator_funcs; iterator->sxe = php_sxe_fetch_object(object TSRMLS_CC); - + return (zend_object_iterator*)iterator; } @@ -1339,10 +1348,10 @@ static void php_sxe_iterator_dtor(zend_object_iterator *iter TSRMLS_DC) php_sxe_iterator *iterator = (php_sxe_iterator *)iter; zval_ptr_dtor((zval**)&iterator->intern.data); - + efree(iterator); } - + static int php_sxe_iterator_has_more(zend_object_iterator *iter TSRMLS_DC) { php_sxe_iterator *iterator = (php_sxe_iterator *)iter; @@ -1402,7 +1411,7 @@ ZEND_API void php_sxe_move_forward_iterator(php_sxe_object *sxe TSRMLS_DC) SKIP_TEXT(node); if (sxe->iter.type != SXE_ITER_ATTRLIST && node->type == XML_ELEMENT_NODE) { - if (sxe->iter.type == SXE_ITER_ELEMENT) { + if (sxe->iter.type == SXE_ITER_ELEMENT) { if (!xmlStrcmp(node->name, sxe->iter.name) && match_ns(sxe, node, prefix)) { break; } @@ -1483,7 +1492,7 @@ PHP_FUNCTION(simplexml_import_dom) } ce = *pce; } - + sxe = php_sxe_object_new(ce TSRMLS_CC); sxe->document = object->document; php_libxml_increment_doc_ref((php_libxml_node_object *)sxe, nodep->doc TSRMLS_CC); @@ -1569,7 +1578,7 @@ PHP_MINFO_FUNCTION(simplexml) php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); php_info_print_table_row(2, "Revision", "$Revision$"); - php_info_print_table_row(2, "Schema support", + php_info_print_table_row(2, "Schema support", #ifdef LIBXML_SCHEMAS_ENABLED "enabled"); #else diff --git a/ext/sqlite/sqlite.c b/ext/sqlite/sqlite.c index 21291de458..7476f13152 100644 --- a/ext/sqlite/sqlite.c +++ b/ext/sqlite/sqlite.c @@ -757,7 +757,7 @@ static int sqlite_free_persistent(list_entry *le, void *ptr TSRMLS_DC) return le->ptr == ptr ? ZEND_HASH_APPLY_REMOVE : ZEND_HASH_APPLY_KEEP; } -static void sqlite_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) +static void sqlite_object_free_storage(void *object TSRMLS_DC) { sqlite_object *intern = (sqlite_object *)object; @@ -791,7 +791,7 @@ static void sqlite_object_new(zend_class_entry *class_type, zend_object_handlers zend_hash_init(intern->std.properties, 0, NULL, ZVAL_PTR_DTOR, 0); zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); - retval->handle = zend_objects_store_put(intern, sqlite_object_dtor, NULL TSRMLS_CC); + retval->handle = zend_objects_store_put(intern, NULL, sqlite_object_free_storage, NULL TSRMLS_CC); retval->handlers = handlers; } diff --git a/ext/tidy/php_tidy.h b/ext/tidy/php_tidy.h index 4fbf95fca4..06dbfb160f 100644 --- a/ext/tidy/php_tidy.h +++ b/ext/tidy/php_tidy.h @@ -200,7 +200,7 @@ struct _PHPTidyObj { }; static char *php_tidy_file_to_mem(char *, zend_bool TSRMLS_DC); -static void tidy_object_dtor(void *, zend_object_handle TSRMLS_DC); +static void tidy_object_free_storage(void * TSRMLS_DC); static zend_object_value tidy_object_new_node(zend_class_entry * TSRMLS_DC); static zend_object_value tidy_object_new_doc(zend_class_entry * TSRMLS_DC); static zend_object_value tidy_object_new_exception(zend_class_entry * TSRMLS_DC); diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 3c9a462e33..30f0688e87 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -317,7 +317,7 @@ static char *php_tidy_file_to_mem(char *filename, zend_bool use_include_path TSR return data; } -static void tidy_object_dtor(void *object, zend_object_handle handle TSRMLS_DC) +static void tidy_object_free_storage(void *object TSRMLS_DC) { PHPTidyObj *intern = (PHPTidyObj *)object; @@ -382,7 +382,7 @@ static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers * break; } - retval->handle = zend_objects_store_put(intern, tidy_object_dtor, NULL TSRMLS_CC); + retval->handle = zend_objects_store_put(intern, NULL, tidy_object_free_storage, NULL TSRMLS_CC); retval->handlers = handlers; } diff --git a/ext/xsl/php_xsl.c b/ext/xsl/php_xsl.c index 29255c991a..31c9192ea6 100644 --- a/ext/xsl/php_xsl.c +++ b/ext/xsl/php_xsl.c @@ -74,8 +74,8 @@ void xsl_objects_clone(void *object, void **object_clone TSRMLS_DC) } /* }}} */ -/* {{{ xsl_objects_dtor */ -void xsl_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC) +/* {{{ xsl_objects_free_storage */ +void xsl_objects_free_storage(void *object TSRMLS_DC) { xsl_object *intern = (xsl_object *)object; @@ -119,7 +119,7 @@ zend_object_value xsl_objects_new(zend_class_entry *class_type TSRMLS_DC) zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *)); ALLOC_HASHTABLE(intern->parameter); zend_hash_init(intern->parameter, 0, NULL, ZVAL_PTR_DTOR, 0); - retval.handle = zend_objects_store_put(intern, xsl_objects_dtor, xsl_objects_clone TSRMLS_CC); + retval.handle = zend_objects_store_put(intern, NULL, xsl_objects_free_storage, xsl_objects_clone TSRMLS_CC); intern->handle = retval.handle; retval.handlers = &xsl_object_handlers; return retval; diff --git a/ext/xsl/php_xsl.h b/ext/xsl/php_xsl.h index f0933063c9..bd71315932 100644 --- a/ext/xsl/php_xsl.h +++ b/ext/xsl/php_xsl.h @@ -60,7 +60,7 @@ typedef struct _xsl_object { } xsl_object; void php_xsl_set_object(zval *wrapper, void *obj TSRMLS_DC); -void xsl_objects_dtor(void *object, zend_object_handle handle TSRMLS_DC); +void xsl_objects_free_storage(void *object TSRMLS_DC); zval *php_xsl_create_object(xsltStylesheetPtr obj, int *found, zval *wrapper_in, zval *return_value TSRMLS_DC); #define REGISTER_XSL_CLASS(ce, name, parent_ce, funcs, entry) \