summaryrefslogtreecommitdiff
path: root/ext/dom/php_dom.c
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2008-01-25 16:13:04 +0000
committerRob Richards <rrichards@php.net>2008-01-25 16:13:04 +0000
commit3e69124430807536b554a1afab52bed4233ad01d (patch)
treeea0dd303c7929f60db4388d24cd8e1e8bdeb0367 /ext/dom/php_dom.c
parentb65adbb4fb6f1e8d37cba31ffdfa64c974bb0381 (diff)
downloadphp-git-3e69124430807536b554a1afab52bed4233ad01d.tar.gz
backport functionality to call user functions within XPath
add test
Diffstat (limited to 'ext/dom/php_dom.c')
-rw-r--r--ext/dom/php_dom.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 30b1968195..f854bafc72 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -960,7 +960,7 @@ void node_list_unlink(xmlNodePtr node TSRMLS_DC)
/* {{{ dom_xpath_objects_free_storage */
void dom_xpath_objects_free_storage(void *object TSRMLS_DC)
{
- dom_object *intern = (dom_object *)object;
+ dom_xpath_object *intern = (dom_xpath_object *)object;
zend_object_std_dtor(&intern->std TSRMLS_CC);
@@ -970,6 +970,14 @@ void dom_xpath_objects_free_storage(void *object TSRMLS_DC)
intern->ptr = NULL;
}
+ zend_hash_destroy(intern->registered_phpfunctions);
+ FREE_HASHTABLE(intern->registered_phpfunctions);
+
+ if (intern->node_list) {
+ zend_hash_destroy(intern->node_list);
+ FREE_HASHTABLE(intern->node_list);
+ }
+
efree(object);
}
/* }}} */
@@ -1026,7 +1034,12 @@ static dom_object* dom_objects_set_class(zend_class_entry *class_type, zend_bool
zval *tmp;
dom_object *intern;
- intern = emalloc(sizeof(dom_object));
+ if (instanceof_function(class_type, dom_xpath_class_entry TSRMLS_CC)) {
+ intern = emalloc(sizeof(dom_xpath_object));
+ memset(intern, 0, sizeof(dom_xpath_object));
+ } else {
+ intern = emalloc(sizeof(dom_object));
+ }
intern->ptr = NULL;
intern->prop_handler = NULL;
intern->document = NULL;
@@ -1097,9 +1110,15 @@ zend_object_value dom_objects_new(zend_class_entry *class_type TSRMLS_DC)
zend_object_value dom_xpath_objects_new(zend_class_entry *class_type TSRMLS_DC)
{
zend_object_value retval;
- dom_object *intern;
-
- intern = dom_objects_set_class(class_type, 1 TSRMLS_CC);
+ dom_xpath_object *intern;
+
+ intern = (dom_xpath_object *)dom_objects_set_class(class_type, 1 TSRMLS_CC);
+ intern->registerPhpFunctions = 0;
+ intern->registered_phpfunctions = NULL;
+ intern->node_list = NULL;
+
+ ALLOC_HASHTABLE(intern->registered_phpfunctions);
+ zend_hash_init(intern->registered_phpfunctions, 0, NULL, ZVAL_PTR_DTOR, 0);
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t)dom_xpath_objects_free_storage, dom_objects_clone TSRMLS_CC);
intern->handle = retval.handle;