mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
applied a small buffer performance patch from Gary Pennington Daniel
* xmlIO.c: applied a small buffer performance patch from Gary Pennington Daniel
This commit is contained in:
@ -1,3 +1,7 @@
|
|||||||
|
Thu May 16 10:43:26 CEST 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* xmlIO.c: applied a small buffer performance patch from Gary Pennington
|
||||||
|
|
||||||
Wed May 15 00:25:34 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
|
Wed May 15 00:25:34 CEST 2002 Igor Zlatkovic <igor@stud.fh-frankfurt.de>
|
||||||
|
|
||||||
* win32/libxml2.def.src: exported xmlXPathNodeSetAddNs()
|
* win32/libxml2.def.src: exported xmlXPathNodeSetAddNs()
|
||||||
|
17
xmlIO.c
17
xmlIO.c
@ -2114,6 +2114,7 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
int res = 0;
|
int res = 0;
|
||||||
int nbchars = 0;
|
int nbchars = 0;
|
||||||
int buffree;
|
int buffree;
|
||||||
|
int needSize;
|
||||||
|
|
||||||
if ((len <= MINLEN) && (len != 4))
|
if ((len <= MINLEN) && (len != 4))
|
||||||
len = MINLEN;
|
len = MINLEN;
|
||||||
@ -2126,12 +2127,15 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
if (len > buffree)
|
if (len > buffree)
|
||||||
len = buffree;
|
len = buffree;
|
||||||
|
|
||||||
buffer = (char *) xmlMalloc((len + 1) * sizeof(char));
|
needSize = in->buffer->use + len + 1;
|
||||||
if (buffer == NULL) {
|
if (needSize > in->buffer->size){
|
||||||
|
if (!xmlBufferResize(in->buffer, needSize)){
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlParserInputBufferGrow : out of memory !\n");
|
"xmlBufferAdd : out of memory!\n");
|
||||||
return(-1);
|
return(0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
buffer = (char *)&in->buffer->content[in->buffer->use];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call the read method for this I/O type.
|
* Call the read method for this I/O type.
|
||||||
@ -2143,12 +2147,10 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
} else {
|
} else {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"xmlParserInputBufferGrow : no input !\n");
|
"xmlParserInputBufferGrow : no input !\n");
|
||||||
xmlFree(buffer);
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
perror ("read error");
|
perror ("read error");
|
||||||
xmlFree(buffer);
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
len = res;
|
len = res;
|
||||||
@ -2172,15 +2174,14 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nbchars = len;
|
nbchars = len;
|
||||||
|
in->buffer->use += nbchars;
|
||||||
buffer[nbchars] = 0;
|
buffer[nbchars] = 0;
|
||||||
xmlBufferAdd(in->buffer, (xmlChar *) buffer, nbchars);
|
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_INPUT
|
#ifdef DEBUG_INPUT
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
"I/O: read %d chars, buffer %d/%d\n",
|
"I/O: read %d chars, buffer %d/%d\n",
|
||||||
nbchars, in->buffer->use, in->buffer->size);
|
nbchars, in->buffer->use, in->buffer->size);
|
||||||
#endif
|
#endif
|
||||||
xmlFree(buffer);
|
|
||||||
return(nbchars);
|
return(nbchars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user