Re: [xml] How to properly free a string allocated by xmlCharStrdup

On 12/26/2013 14:19, Shlomi Fish wrote:
Hi all,

happy holidays and a happy new (civil) year.

I'm the maintainer of XML::LibXSLT which are the CPAN bindings for libxslt.
Now, someone reported that the clang compiler emits some warnings, and part of
the problem was that I passed "1.0" to xmlNewDoc instead of its equivalent
"xmlChar *". So I did:

xmlChar * xml_ver = NULL;
xml_ver = xmlCharStrdup("1.0");

// At the function FINISH:
free( xml_ver );

Use xmlFree(). But for this particular case you don't need to allocate anything, just do xmlNewDoc(NULL).

How can I properly free a string allocated by xmlCharStrdup? The documentation
is lacking on details (and, if you ask me, should be made more explicit.).
You got all the code, for that case it's pretty simple.


        Shlomi Fish

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