destroy = del;
}
-XMLBuffer::XMLBuffer(long buf_size, const char *buf, int del)
+XMLBuffer::XMLBuffer(long buf_size, char *buf, int del)
{ // writing
bfr = (unsigned char *)buf;
bsz = buf_size;
if( destroy ) delete [] bfr;
}
-unsigned char *&XMLBuffer::demand(long len)
+int XMLBuffer::demand(long len)
{
if( len > bsz ) {
+ if( !destroy ) return 0;
long sz = inp-bfr;
len += sz/2 + BCTEXTLEN;
unsigned char *np = new unsigned char[len];
lmt = np + len; bsz = len;
delete [] bfr; bfr = np;
}
- return bfr;
+ return 1;
}
int XMLBuffer::write(const char *bp, int len)
{
- if( !destroy && lmt-inp < len ) len = lmt-inp;
if( len <= 0 ) return 0;
+ if( !destroy && lmt-inp < len ) len = lmt-inp;
demand(otell()+len);
memmove(inp,bp,len);
inp += len;
++pos;
}
// if end tag is reached, pos is left on the < of the end tag
- if( !skip && pos >= 0 && !tag_end[pos] && !skip )
+ if( !skip && pos >= 0 && !tag_end[pos] )
buffer->iseek(ipos);
return opos;
}