mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-23 01:52:48 +03:00
buf: Rework xmlBuf code
Always use what the old implementation called the "IO" allocation scheme, allowing to move the content pointer past the initial allocation. This is inexpensive and allows efficient shrinking. Optimize xmlBufGrow, reusing shrunken memory as much as possible. Simplify xmlBufAdd. Make xmlBufBackToBuffer return an error on overflow. Make "size" exclude the terminating NULL byte. Always provide an initial size. Reintroduce static buffers. Remove xmlBufResize and several other functions.
This commit is contained in:
12
HTMLtree.c
12
HTMLtree.c
@@ -460,7 +460,8 @@ htmlBufNodeDumpFormat(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur,
|
||||
int
|
||||
htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
||||
xmlBufPtr buffer;
|
||||
size_t ret;
|
||||
size_t ret1;
|
||||
int ret2;
|
||||
|
||||
if ((buf == NULL) || (cur == NULL))
|
||||
return(-1);
|
||||
@@ -470,14 +471,13 @@ htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
|
||||
if (buffer == NULL)
|
||||
return(-1);
|
||||
|
||||
xmlBufSetAllocationScheme(buffer, XML_BUFFER_ALLOC_DOUBLEIT);
|
||||
ret = htmlBufNodeDumpFormat(buffer, doc, cur, 1);
|
||||
ret1 = htmlBufNodeDumpFormat(buffer, doc, cur, 1);
|
||||
|
||||
xmlBufBackToBuffer(buffer);
|
||||
ret2 = xmlBufBackToBuffer(buffer, buf);
|
||||
|
||||
if (ret > INT_MAX)
|
||||
if ((ret1 == (size_t) -1) || (ret2 < 0))
|
||||
return(-1);
|
||||
return((int) ret);
|
||||
return(ret1 > INT_MAX ? INT_MAX : ret1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user