helly Sat Oct 25 17:08:40 2003 EDT Modified files: /php-src/ext/simplexml php_simplexml.h simplexml.c Log: Fix memleaks Index: php-src/ext/simplexml/php_simplexml.h diff -u php-src/ext/simplexml/php_simplexml.h:1.6 php-src/ext/simplexml/php_simplexml.h:1.7 --- php-src/ext/simplexml/php_simplexml.h:1.6 Sat Jun 14 14:15:50 2003 +++ php-src/ext/simplexml/php_simplexml.h Sat Oct 25 17:08:33 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_simplexml.h,v 1.6 2003/06/14 18:15:50 rrichards Exp $ */ +/* $Id: php_simplexml.h,v 1.7 2003/10/25 21:08:33 helly Exp $ */ #ifndef PHP_SIMPLEXML_H #define PHP_SIMPLEXML_H @@ -62,6 +62,7 @@ simplexml_ref_obj *document; xmlHashTablePtr nsmap; xmlXPathContextPtr xpath; + HashTable *properties; } php_sxe_object; Index: php-src/ext/simplexml/simplexml.c diff -u php-src/ext/simplexml/simplexml.c:1.66 php-src/ext/simplexml/simplexml.c:1.67 --- php-src/ext/simplexml/simplexml.c:1.66 Sat Oct 25 16:28:39 2003 +++ php-src/ext/simplexml/simplexml.c Sat Oct 25 17:08:33 2003 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: simplexml.c,v 1.66 2003/10/25 20:28:39 helly Exp $ */ +/* $Id: simplexml.c,v 1.67 2003/10/25 21:08:33 helly Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -350,7 +350,7 @@ /* {{{ _get_base_node_value() */ static void -_get_base_node_value(xmlNodePtr node, zval **value TSRMLS_DC) +_get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval **value TSRMLS_DC) { php_sxe_object *subnode; char *contents; @@ -364,14 +364,13 @@ } } else { subnode = php_sxe_object_new(TSRMLS_C); - subnode->document = emalloc(sizeof(simplexml_ref_obj)); - subnode->document->refcount = 1; - subnode->document->ptr = node->doc; + subnode->document = sxe_ref->document; + subnode->document->refcount++; subnode->node = node; (*value)->type = IS_OBJECT; (*value)->value.obj = php_sxe_register_object(subnode TSRMLS_CC); - zval_add_ref(value); + /*zval_add_ref(value);*/ } } /* }}} */ @@ -391,18 +390,24 @@ ulong h; int namelen; - ALLOC_HASHTABLE(rv); - zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); - sxe = php_sxe_fetch_object(object TSRMLS_CC); + if (sxe->properties) { + zend_hash_clean(sxe->properties); + rv = sxe->properties; + } else { + ALLOC_HASHTABLE(rv); + zend_hash_init(rv, 0, NULL, ZVAL_PTR_DTOR, 0); + sxe->properties = rv; + } + GET_NODE(sxe, node); node = node->children; while (node) { SKIP_TEXT(node); - _get_base_node_value(node, &value TSRMLS_CC); + _get_base_node_value(sxe, node, &value TSRMLS_CC); name = (char *) node->name; namelen = xmlStrlen(node->name) + 1; @@ -890,6 +895,11 @@ if (sxe->xpath) { xmlXPathFreeContext(sxe->xpath); } + + if (sxe->properties) { + zend_hash_destroy(sxe->properties); + FREE_HASHTABLE(sxe->properties); + } efree(object); } @@ -909,6 +919,7 @@ intern->document = NULL; intern->nsmap = NULL; intern->xpath = NULL; + intern->properties = NULL; ALLOC_HASHTABLE(intern->zo.properties); zend_hash_init(intern->zo.properties, 0, NULL, ZVAL_PTR_DTOR, 0); @@ -1075,7 +1086,7 @@ { php_info_print_table_start(); php_info_print_table_header(2, "Simplexml support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.66 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.67 $"); php_info_print_table_end(); } /* }}} */
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php