[xslt] xmlStrdup() do I need to free it?



Hi All,

I recently added the libxslt library to my project. I'm writing a Mac OS X app and using the libxslt.framework. I have a string of XML as a Cocoa object. I can get a UTF8String from that string object but it is not mutable, it's const char *. I call xmlParseDoc() with my string but xmlParseDoc() wants a mutable string so I copied it with xmlStrdup(). Now I feel like I should be freeing the memory from xmlStrdup() but I don't see what I should be using. I was calling xmlMemFree() but that is printing an error. Below is my code. Do I need to free this memory? How do I do it? The docs are a little sparse on this.

xmlChar *xmlStringPtr;
xmlDoc *document = NULL;

// get utf 8 string from xmlString

xmlStringPtr = xmlStrdup([xmlString UTF8String]);

// parse string into xmlDoc
document = xmlParseDoc(xmlStringPtr);

Thanks
Marc



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