Re: How to check if DTD or Doc is loaded ?



Den 2017-11-06 kl. 15:06, skrev Mat D:
Hi everyone,

I am using the c++ Libxml Lib & I want to free DTD & xml loaded ONLY if they are .
Because if I use those functions twice it crash the lib because documents have already been free :

xmlFreeDtd();
xmlFreeDoc();

How to check if a dtd/doc is loaded ?

I tried things as: 
if(dtdPtr->type == XML_DTD_NODE){
  std::cout << "free memory now .." << std::endl;
  xmlFreeDtd(dtdPtr);
}
But it does not work :s
Thanks by advance for help!!

If you use the C++ library, libxml++, don't call xmlFreeDtd() or xmlFreeDoc() yourself. Let the C++ classes do that. If you want to free a DTD or a document, delete the corresponding xmlpp::Dtd or xmlpp::Document instance.

If you use the C library, libxml2, directly, clear the pointer after the call to xmlFreeDtd() or xmlFreeDoc().
  xmlFreeDoc(mydoc);
  mydoc = nullptr;  // mydoc = NULL; if you use a C compiler.
Any access to freed memory is an error.

/Kjell


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