Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:100749 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 24018 invoked from network); 22 Sep 2017 11:01:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Sep 2017 11:01:30 -0000 Authentication-Results: pb1.pair.com header.from=oneil@saxonica.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=oneil@saxonica.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain saxonica.com from 217.69.43.196 cause and error) X-PHP-List-Original-Sender: oneil@saxonica.com X-Host-Fingerprint: 217.69.43.196 UK1MAIL2513-b.mymailbank.co.uk Received: from [217.69.43.196] ([217.69.43.196:54219] helo=uk1mail2513-b.mymailbank.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E9/6B-62331-78DE4C95 for ; Fri, 22 Sep 2017 07:01:28 -0400 Received: from [192.168.0.11] (cpc81936-leic18-2-0-cust39.8-1.cable.virginm.net [82.6.254.40]) by uk1mail2513-d.mymailbank.co.uk with SMTP; Fri, 22 Sep 2017 12:00:55 +0100 Content-Type: multipart/alternative; boundary="Apple-Mail=_E5E5DEA7-E9D9-48A8-B08C-34DE17F7F8B9" Message-ID: <4DE419BB-2630-44B8-B4E7-98E17BEBE749@saxonica.com> Date: Fri, 22 Sep 2017 12:01:19 +0100 To: PHP internals Mime-Version: 1.0 (Mac OS X Mail 9.3 \(3124\)) X-Mailer: Apple Mail (2.3124) Subject: PHP extension - Saxon/C From: oneil@saxonica.com (O'Neil Delpratt) --Apple-Mail=_E5E5DEA7-E9D9-48A8-B08C-34DE17F7F8B9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hi, I am having a problem in my PHP extension and I am wondering if you can = give me some advise or even a pointer.=20 We have the following class object XQueryProcessor and XdmNode. The following method takes the XdmNode as parameter: = XQueryProcessor.setContextItem(XdmNode) Any idea what is going wrong in the code below? The XdmNode in my PHP = class is a wrapper for a C/C++ object which is held in the = XQueryProcessor. Do I have to add some special refcount to the PHP = XdmNode? This is giving a memory leak warning: [Fri Sep 22 08:56:42 2017] Script: = '/home/ond1/work/svn/latest9.8-saxonc/hec/samples/php/xqueryExamples.php' = /home/ond1/work/svn/latest9.8-saxonc/hec/Saxon.C.API/php7_saxon.cpp(3250) = : Freeing 0x00007ffff68863c0 (48 bytes), = script=3D/home/ond1/work/svn/latest9.8-saxonc/hec/samples/php/xqueryExampl= es.php = /home/ond1/work/svn/latest9.8-saxonc/hec/Saxon.C.API/php7-src/php-src/Zend= /zend_alloc.c(2472) : Actual location (location was relayed) =3D=3D=3D Total 1 memory leaks detected =3D=3D=3D The code in question is at follows: PHP_METHOD(XQueryProcessor, setContextItem) { char * context; int len1; zval* oth; XQueryProcessor *xqueryProcessor; if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &oth) =3D=3D = FAILURE) { RETURN_NULL(); } if(oth !=3D NULL) { zend_object* pobj =3D Z_OBJ_P(getThis());=20 xqueryProcessor_object *obj =3D (xqueryProcessor_object *)((char = *)pobj - XtOffsetOf(xqueryProcessor_object, std)); xqueryProcessor =3D obj->xqueryProcessor; const char * objName =3DZSTR_VAL(Z_OBJCE_P(oth)->name); Z_ADDREF_P(oth); =09 if(strcmp(objName, "Saxon\\XdmNode")=3D=3D0) { zend_object *vvobj =3D Z_OBJ_P(oth); xdmNode_object* ooth =3D (xdmNode_object *)((char *)vvobj - = XtOffsetOf(xdmNode_object, std)); if(ooth !=3D NULL) { XdmNode * value =3D ooth->xdmNode; if(value !=3D NULL) { Z_ADDREF(*oth);=09 xqueryProcessor->setContextItem((XdmItem *)value); return; } } } else =E2=80=A6=E2=80=A6. See full code of PHP extension: = https://dev.saxonica.com/repos/archive/opensource/latest9.8/hec/Saxon.C.AP= I/php7_saxon.cpp = kind regards, O'Neil ------------------------------- O'Neil Delpratt Software Developer, Saxonica Limited=20 Email: oneil@saxonica.com Twitter: https://twitter.com/ond1 Tel: +44 118 946 5894 Web: http://www.saxonica.com Saxonica Community site: http://dev.saxonica.com Bug tracking site: https://saxonica.plan.io/ --Apple-Mail=_E5E5DEA7-E9D9-48A8-B08C-34DE17F7F8B9--