Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:43293 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 30949 invoked from network); 10 Mar 2009 16:30:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Mar 2009 16:30:27 -0000 Received: from [127.0.0.1] ([127.0.0.1:10468]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 26/F9-15363-3A596B94 for ; Tue, 10 Mar 2009 11:30:27 -0500 X-Host-Fingerprint: 128.8.183.2 www.langsource.umd.edu Received: from [128.8.183.2] ([128.8.183.2:16534] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 40/59-15363-61396B94 for ; Tue, 10 Mar 2009 11:19:35 -0500 To: internals@lists.php.net Date: Tue, 10 Mar 2009 12:19:32 -0400 Message-ID: <2009031012193216807-fdintino@nflcorg> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Unison/1.8.1 X-Posted-By: 128.8.183.2 Subject: Cloning of objects passed as parameters From: fdintino@nflc.org (Frankie Dintino) 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); } }