You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Sree Harsha <sr...@gmail.com> on 2008/02/16 04:26:39 UTC
Reusing a pointer to DOMElement*??
Hi all,
Is it possible to re-use a pointer to a DOMElement* as follows
xercesc::DOMElement*
xercesElement=(xercesc::DOMElement*)Nlist_ProcessIndex->item(0);
const XMLCh* ccharProcessIndex = xercesElement->getTextContent( ) ;
xercesc::DOMElement*
xercesElement=(xercesc::DOMElement*)Nlist_Sequence->item(0);
const XMLCh* ccharSequence= xercesElement->getTextContent( ) ;
will it cause memory leaks?? should i delete or free (Pointer to
DOMElement*) xercesElement?? will the use of XMLCh* as above cause
memory leaks?? should i free or delete the (Pointer to XMLCh) XMLCh*
variables...
Thanks n Regards
Sree Harsha Vardhana S.N
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: Reusing a pointer to DOMElement*??
Posted by Alberto Massari <am...@datadirect.com>.
Sree Harsha wrote:
> Hi all,
> Is it possible to re-use a pointer to a DOMElement* as follows
>
> xercesc::DOMElement*
> xercesElement=(xercesc::DOMElement*)Nlist_ProcessIndex->item(0);
> const XMLCh* ccharProcessIndex = xercesElement->getTextContent( ) ;
> xercesc::DOMElement*
> xercesElement=(xercesc::DOMElement*)Nlist_Sequence->item(0);
> const XMLCh* ccharSequence= xercesElement->getTextContent( ) ;
>
> will it cause memory leaks?? should i delete or free (Pointer to
> DOMElement*) xercesElement?? will the use of XMLCh* as above cause
> memory leaks?? should i free or delete the (Pointer to XMLCh) XMLCh*
> variables...
>
Hi Sree,
both pointers (DOMElement and XMLCh) should not be deleted, as they are
owned by the DOMDocument and will be deleted when the document is
deleted. Only be sure to delete the char* returned by
XMLString::transcode, if you invoke it on the XMLCh* buffer.
Alberto
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
Re: Reusing a pointer to DOMElement*??
Posted by Ozgur Sahoglu <oz...@gmail.com>.
The question is not clear to me. If you're defining xercesElement in the
same scope, this thing won't even compile; you'll get a redecleration error.
You don't delete anything, if you haven't allocated it. You use 'delete' in
respect to 'new'. In your code snippet, you are just declaring pointers to
DOM elements in your document (or to XMLCh string), you are not actually
allocating memory for them. Therefore, you don't delete them.
-Ozgur Sahoglu
On Feb 15, 2008 7:26 PM, Sree Harsha <sr...@gmail.com> wrote:
> Hi all,
> Is it possible to re-use a pointer to a DOMElement* as follows
>
> xercesc::DOMElement*
> xercesElement=(xercesc::DOMElement*)Nlist_ProcessIndex->item(0);
> const XMLCh* ccharProcessIndex = xercesElement->getTextContent( ) ;
> xercesc::DOMElement*
> xercesElement=(xercesc::DOMElement*)Nlist_Sequence->item(0);
> const XMLCh* ccharSequence= xercesElement->getTextContent( ) ;
>
> will it cause memory leaks?? should i delete or free (Pointer to
> DOMElement*) xercesElement?? will the use of XMLCh* as above cause
> memory leaks?? should i free or delete the (Pointer to XMLCh) XMLCh*
> variables...
>
> Thanks n Regards
> Sree Harsha Vardhana S.N
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: c-dev-help@xerces.apache.org
>
>