Re: [xml] XPathObject and user/user2

On Fri, 2002-11-29 at 13:17, Daniel Veillard wrote:
On Fri, Nov 29, 2002 at 12:50:17PM +0100, Christian Stocker wrote:

I'm trying to debug (once again) PHPs domxml extension.

The XPath part of domxml uses obj->user (obj is a xmlXPathObjectPtr) for

  that's bad !

storing a PHP/Zend internal pointer. But when I look into the source of
xpath.c, then I see that obj->user is also used internally there. 

  yes, user is needed for XSLT extensions and XPointer entensions. 
user2 is used solely for XPointer, so this might be safer to use.

Is my assumption right, that obj->user (and user2 for that matter),
shouldn't be used for application side storage of pointers like _private
in other structs? 


Is there an alternative for that (interpreting there
isn't..) ?

   there isn't in general, user2 seems safer.

If so, I wonder why it never crashed on me, but it could explain some
memory leaks on my side.

   Seems unlikely unless it also uses XSLT with the same objects,
but having a crash sounds more probable, code like:
   xmlFreeNodeList((xmlNodePtr) obj->user);
with a pointer to PHP objects is likely to make a lot of damages !
And this is part of xmlXPathFreeObject(), so this hack looks really really

I feared that... It looks like I have to rewrite this XPath stuff then,
since there are unfortunately no _private members in those structs.

Anyway, thanks a lot for your answer.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]