Hi Nikolay, On Thu, 26 Dec 2013 14:58:27 +0400 Nikolay Sivov <bungleh...@gmail.com> wrote:
> 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"); > > xmlNewDoc(xml_ver) > > > > // 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). Thanks! Hopefully it will work well. I credited you in the "Changes" file. > > > > 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. Well, the fact is that I got it wrong. And twice. Also see what Joel on Software wrote about fixing every problem two ways here: http://www.joelonsoftware.com/articles/customerservice.html Just for reference I refer to http://xmlsoft.org/html/libxml-xmlstring.html#xmlCharStrdup which says it is «a strdup for char's to xmlChar's» and does not tell one how to free it (in fact the string «xmlFree» does not appear anywhere on the page), which prompted me to ask the question after getting a segmentation fault for that on Windows. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Freecell Solver - http://fc-solve.shlomifish.org/ I HAVE NEITHER BEEN THERE NOR DONE THAT — Bart Simpson on chalkboard in episode AABF17 Please reply to list if it's a mailing list post - http://shlom.in/reply . _______________________________________________ xml mailing list, project page http://xmlsoft.org/ xml@gnome.org https://mail.gnome.org/mailman/listinfo/xml