Joy
Joy

Reputation: 1777

the use of XMLString::release( XMLCh ** buf)

I'm using xerces-c++ I don't seem to really get the use of XMLString::release ( XMLCh ** buf) so right now I'm using it every time I want to reuse a local variable like this:

XMLCh* xmlStringVar = XMLString::Transcode("name");
XMLCh* fieldName = fieldsNodeList[NbreFlds]->getAttribute(xmlStringVar));
XMLString::release(&xmlStringVar);
xmlStringVar = XMLString::Transcode("id");
XMLCh* fieldId = fieldsNodeList[NbreFlds]->getAttribute(xmlStringVar));

please correct to me this code if something is wrong and if you got a clearer description of the function XMLString::release please inform me.

Upvotes: 1

Views: 2736

Answers (2)

xaero99
xaero99

Reputation: 327

Xerces documentation says: "The implementation will call MemoryManager::deallocate and then turn the string to a null pointer." To assign the string to a null pointer it requires address of the string pointer. If it was deallocation only, passing pointer (instead of address of the pointer) would be sufficient.

Upvotes: 1

Clemens
Clemens

Reputation: 1817

Looks perfectly valid. As the documentation for XMLString::release says use it to free memory allocated by the transcode() function.

Upvotes: 1

Related Questions