I'm writing a PHP class with a method that has to be passed a DOMDocument object, and it needs to retain that object throughout the life of its instantiation. However, the (dom_object *) returned from zend_parse_method_parameters is just a pointer to the passed object, and so it disappears when the original document is unset or goes out of scope. How would one go about cloning the DOMDocument to save in the class's struct?

example:
ZEND_METHOD(xydelta, setStartDocument) {
        zval *id, *doc = NULL;
        xydelta_object *intern;

if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Oo", &id, xydelta_ce, &doc) == FAILURE) {
                RETURN_FALSE;
        }

        intern = (xydelta_object *)zend_object_store_get_object(id TSRMLS_CC);
        if (intern != NULL) {   
                // Error checking removed for brevity...
                // ...

// This pointer cannot be accessed once the object that was used as the first parameter goes out of scope intern->libxml_start_doc = (php_libxml_node_object *) zend_object_store_get_object(doc TSRMLS_CC);
        }
}


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to