[Expat-discuss] need to free after calling XML_GetBuffer?

Guoquan Lee lee_guoquan at hotmail.com
Sun Mar 13 03:49:04 CET 2005


Hi

I am having some error using expat in c++.  I get XML_STATUS_ERROR after 
calling XML_GetBuffer.  I am calling XML_GetBuffer within a while loop like 
this:

while(carry_on)
{
  void *buff = XML_GetBuffer(p,10240); // p is a xml parser
  if(buff == NULL) return;
  bytes_read = read(fd, buff, 10240); //fd is a file descriptor pointing to 
a xml document of interest
  if(bytes_read < 0) return;
  status = XML_ParseBuffer(p, buff, bytes_read, bytes_read==0); //status is 
of type XML_Status
  if(status ==XML_STATUS_ERROR)
   {
    std::cout<<"status error"<<"\n";
    return;
   }
}

I looked into the contents of buff when the program reported 
XML_STATUS_ERROR and realized that some of the contents in buff were from 
the previous iteration of XML_GetBuffer.  Why is that?  What is the cause of 
XML_STATUS_ERROR and how to rectify it?

Thank you.

_________________________________________________________________
Get an advanced look at the new version of MSN Messenger. 
http://messenger.msn.com.sg/Beta/Default.aspx



More information about the Expat-discuss mailing list