if (((xsltStylesheetPtr) intern->ptr)->_private != NULL) {
((xsltStylesheetPtr) intern->ptr)->_private = NULL;
}
- /* libxslt uses _private for itself, so turning of the deregistering is maybe a solution
- we copied the doc at import, so it shouldn't be possible to be used from php land */
+ if (intern->document != NULL) {
+ if (--intern->document->refcount == 0) {
+ xmlFreeDoc((xmlDocPtr) intern->document->ptr);
+ efree(intern->document);
+ }
+ ((xsltStylesheetPtr) intern->ptr)->doc = NULL;
+ intern->document = NULL;
+ }
+
xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr);
intern->ptr = NULL;
}
zval *id, *docp = NULL;
xmlDoc *doc = NULL;
xsltStylesheetPtr sheetp, oldsheetp;
- xmlDocPtr newdocp;
xsl_object *intern;
node_object *docobj;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "o", &docp) == FAILURE) {
RETURN_FALSE;
}
+
DOC_GET_OBJ(doc, docp, xmlDocPtr, docobj);
- /* copy the doc, so that it's not accessable from outside
- FIXME: and doubling memory consumption...
- */
- newdocp = xmlCopyDoc(doc, 1);
- sheetp = xsltParseStylesheetDoc(newdocp);
+
+ sheetp = xsltParseStylesheetDoc(doc);
if (!sheetp) {
- xmlFreeDoc(newdocp);
RETURN_FALSE;
}
efree(((xsltStylesheetPtr) intern->ptr)->_private);
((xsltStylesheetPtr) intern->ptr)->_private = NULL;
}
- //FIXME: more non-thread safe stuff
+ if (intern->document != NULL) {
+ if (--intern->document->refcount == 0) {
+ xmlFreeDoc((xmlDocPtr) intern->document->ptr);
+ efree(intern->document);
+ }
+ ((xsltStylesheetPtr) intern->ptr)->doc = NULL;
+ intern->document = NULL;
+ }
xsltFreeStylesheet((xsltStylesheetPtr) intern->ptr);
intern->ptr = NULL;
- }
+ }
+
+ intern->document = docobj->document;
+ intern->document->refcount++;
+
php_xsl_set_object(id, sheetp TSRMLS_CC);
}
/* }}} end xsl_xsltprocessor_import_stylesheet */