1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 12:25:09 +03:00

buf: Don't use default buffer size for small strings

Detaching strings from a buffer with a default size of 4096 can waste
a lot of memory.
This commit is contained in:
Nick Wellnhofer 2024-03-11 13:42:15 +01:00
parent 291a9d0f81
commit 05adfbf880
2 changed files with 7 additions and 7 deletions

10
tree.c
View File

@ -1254,7 +1254,7 @@ xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
cur = value;
end = cur + len;
buf = xmlBufCreateSize(0);
buf = xmlBufCreateSize(64);
if (buf == NULL) return(NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
@ -1487,7 +1487,7 @@ xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
if (value == NULL) return(NULL);
buf = xmlBufCreateSize(0);
buf = xmlBufCreateSize(64);
if (buf == NULL) return(NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
@ -1695,7 +1695,7 @@ xmlNodeListGetStringInternal(xmlDocPtr doc, const xmlNode *node, int escMode) {
xmlBufPtr buf;
xmlChar *ret;
buf = xmlBufCreate();
buf = xmlBufCreateSize(64);
if (buf == NULL)
return(NULL);
@ -5852,7 +5852,7 @@ xmlNodeGetContent(const xmlNode *cur)
if (ent == NULL)
return (NULL);
buf = xmlBufCreate();
buf = xmlBufCreateSize(64);
if (buf == NULL)
return (NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
@ -5868,7 +5868,7 @@ xmlNodeGetContent(const xmlNode *cur)
xmlBufPtr buf;
xmlChar *ret;
buf = xmlBufCreate();
buf = xmlBufCreateSize(64);
if (buf == NULL)
return (NULL);
xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);

View File

@ -8308,7 +8308,7 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
if (ctxt->error != 0)
goto error;
target = xmlBufCreate();
target = xmlBufCreateSize(64);
if (target == NULL) {
xmlXPathPErrMemory(ctxt);
goto error;
@ -13398,7 +13398,7 @@ xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
CAST_TO_STRING;
str = valuePop(ctxt);
target = xmlBufCreate();
target = xmlBufCreateSize(64);
escape[0] = '%';
escape[3] = 0;