[Expat-discuss] XML_ParseBuffer keeps returning 4 bytes?

Mohun Biswas m_biswas at mailinator.com
Thu Jul 7 16:42:46 CEST 2005


It sounds like you're confusing the size of the pointer with the size of 
the buffer it points to. The size of a *pointer* will almost always be 4 
bytes. The size of the area it points at is whatever you allocate. You 
didn't post code but consider the sample code in reference.html:

for (;;) {
   int bytes_read;
   void *buff = XML_GetBuffer(p, BUFF_SIZE);
   if (buff == NULL) {
     /* handle error */
   }

   bytes_read = read(docfd, buff, BUFF_SIZE);
   if (bytes_read < 0) {
     /* handle error */
   }

   if (! XML_ParseBuffer(p, bytes_read, bytes_read == 0)) {
     /* handle parse error */
   }

   if (bytes_read == 0)
     break;
}

Sounds like you're using sizeof(buff) in the read() call rather than 
BUFF_SIZE.

MB



More information about the Expat-discuss mailing list