I am using a library called tinyXML, which parses XML files. Many of its methods return a const char*.
After having read this question: how to return a char array from a function in C
I now believe that every time a method returns a char* it is the caller's (my) responsibility to explicitly free it, because it is probably allocated dynamically on the heap. Am I right / wrong? What can I assume?
(If I ever wrote a library I would much rather return std::string instead of char* arrays, because they are so much simpler for the user.)
std::stringclass, and fully supportsstd::istream,std::ostream,operator<<, andoperator>>. Many API methods have bothconst char*andconst std::string&forms." Of course C doesn't havestd::string, so an option to usechar*is still necessary (assuming it can be used from C; I'm not sure of that). Also, the home page suggests that "You may want to consider TinyXML-2".