You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xerces.apache.org by Emre Turkay <em...@vanderbilt.edu> on 2005/06/07 01:21:03 UTC
DOMWriter::writeToString return value
Hi Folks,
I've been using DOMWriter::writeToString() method and free'ing the
returned memory with XMLString::release. When I gave it to valgrind, it
said there is a mismatched malloc/new/free/delete. I've go into the code
and see that a special allocator is used with the name fMemoryManager. I
didn't examine further, I just deleted the XMLString::relase line, and
valgrind stopped complaining.
What I guess is the mentioned allocator somehow deletes the content at
some point, I mean the memory is managed. However, there's nothing in
the documentation talking about it, can someone confirm me? If this is
the case can we add a line to the documentation, so people do not try to
destroy the returned memory?
Thanks,
emre
Re: DOMWriter::writeToString return value
Posted by Emre Turkay <em...@vanderbilt.edu>.
Meanwhile, I can send a patch (probably for the header/doxygen
documentation), however I wanted to be sure first that my assumptions
were correct.
emre
Jason E. Stewart wrote:
>Emre Turkay <em...@vanderbilt.edu> writes:
>
>
>
>>I've been using DOMWriter::writeToString() method and free'ing the
>>returned memory with XMLString::release. When I gave it to valgrind,
>>it said there is a mismatched malloc/new/free/delete. I've go into the
>>code and see that a special allocator is used with the name
>>fMemoryManager. I didn't examine further, I just deleted the
>>XMLString::relase line, and valgrind stopped complaining.
>>
>>What I guess is the mentioned allocator somehow deletes the content at
>>some point, I mean the memory is managed. However, there's nothing in
>>the documentation talking about it, can someone confirm me? If this is
>>the case can we add a line to the documentation, so people do not try
>>to destroy the returned memory?
>>
>>
>
>The DOM programming guide does mention this already - it indicates
>that memory for objects created using createXXXX() from
>DOMImplementation must be freed by calling release(). That includes a
>DOMWriter created using createDOMWriter().
>
>It could be more clear for DOMWriter. If you suggest a patch, I'm sure
>it could be included.
>
>Cheers,
>jas.
>
>
>
Re: DOMWriter::writeToString return value
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
Emre Turkay <em...@vanderbilt.edu> writes:
> I guess there is a misunderstanding, because the method I mentioned is
> returning XMLCh*.
Correct, it's not so clear for DOMWriter what happens to the resources
it makes. It's spelled out more clearly for DOMDocument and
DOMDocumentType.
I ran into this same problem when building the latest Xerces-Perl API.
Cheers,
jas.
Re: DOMWriter::writeToString return value
Posted by Emre Turkay <em...@vanderbilt.edu>.
Hi Jason,
I guess there is a misunderstanding, because the method I mentioned is
returning XMLCh*.
Thanks,
emre
Jason E. Stewart wrote:
>Emre Turkay <em...@vanderbilt.edu> writes:
>
>
>
>>I've been using DOMWriter::writeToString() method and free'ing the
>>returned memory with XMLString::release. When I gave it to valgrind,
>>it said there is a mismatched malloc/new/free/delete. I've go into the
>>code and see that a special allocator is used with the name
>>fMemoryManager. I didn't examine further, I just deleted the
>>XMLString::relase line, and valgrind stopped complaining.
>>
>>What I guess is the mentioned allocator somehow deletes the content at
>>some point, I mean the memory is managed. However, there's nothing in
>>the documentation talking about it, can someone confirm me? If this is
>>the case can we add a line to the documentation, so people do not try
>>to destroy the returned memory?
>>
>>
>
>The DOM programming guide does mention this already - it indicates
>that memory for objects created using createXXXX() from
>DOMImplementation must be freed by calling release(). That includes a
>DOMWriter created using createDOMWriter().
>
>It could be more clear for DOMWriter. If you suggest a patch, I'm sure
>it could be included.
>
>Cheers,
>jas.
>
>
>
Re: DOMWriter::writeToString return value
Posted by "Jason E. Stewart" <ja...@openinformatics.com>.
Emre Turkay <em...@vanderbilt.edu> writes:
> I've been using DOMWriter::writeToString() method and free'ing the
> returned memory with XMLString::release. When I gave it to valgrind,
> it said there is a mismatched malloc/new/free/delete. I've go into the
> code and see that a special allocator is used with the name
> fMemoryManager. I didn't examine further, I just deleted the
> XMLString::relase line, and valgrind stopped complaining.
>
> What I guess is the mentioned allocator somehow deletes the content at
> some point, I mean the memory is managed. However, there's nothing in
> the documentation talking about it, can someone confirm me? If this is
> the case can we add a line to the documentation, so people do not try
> to destroy the returned memory?
The DOM programming guide does mention this already - it indicates
that memory for objects created using createXXXX() from
DOMImplementation must be freed by calling release(). That includes a
DOMWriter created using createDOMWriter().
It could be more clear for DOMWriter. If you suggest a patch, I'm sure
it could be included.
Cheers,
jas.