added xmlMallocAtomic() to be used when allocating blocks which do not
* DOCBparser.c HTMLparser.c c14n.c catalog.c encoding.c globals.c
nanohttp.c parser.c parserInternals.c relaxng.c tree.c uri.c
xmlmemory.c xmlreader.c xmlregexp.c xpath.c xpointer.c
include/libxml/globals.h include/libxml/xmlmemory.h: added
xmlMallocAtomic() to be used when allocating blocks which
do not contains pointers, add xmlGcMemSetup() and xmlGcMemGet()
to allow registering the full set of functions needed by
a garbage collecting allocator like libgc, ref #109944
Daniel
diff --git a/tree.c b/tree.c
index b18c209..abe9cf2 100644
--- a/tree.c
+++ b/tree.c
@@ -156,7 +156,7 @@
lenp = strlen((char *) prefix);
if ((memory == NULL) || (len < lenn + lenp + 2)) {
- ret = (xmlChar *) xmlMalloc(lenn + lenp + 2);
+ ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
if (ret == NULL) return(NULL);
} else {
ret = memory;
@@ -3977,10 +3977,10 @@
return (NULL);
buf_len = 500;
- buffer = (xmlChar *) xmlMalloc(buf_len * sizeof(xmlChar));
+ buffer = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar));
if (buffer == NULL)
return (NULL);
- buf = (xmlChar *) xmlMalloc(buf_len * sizeof(xmlChar));
+ buf = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar));
if (buf == NULL) {
xmlFree(buffer);
return (NULL);
@@ -6087,7 +6087,7 @@
ret->use = 0;
ret->size = xmlDefaultBufferSize;
ret->alloc = xmlBufferAllocScheme;
- ret->content = (xmlChar *) xmlMalloc(ret->size * sizeof(xmlChar));
+ ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
if (ret->content == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlBufferCreate : out of memory!\n");
@@ -6119,7 +6119,7 @@
ret->alloc = xmlBufferAllocScheme;
ret->size = (size ? size+2 : 0); /* +1 for ending null */
if (ret->size){
- ret->content = (xmlChar *) xmlMalloc(ret->size * sizeof(xmlChar));
+ ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
if (ret->content == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlBufferCreate : out of memory!\n");
@@ -6338,7 +6338,7 @@
}
if (buf->content == NULL)
- rebuf = (xmlChar *) xmlMalloc(newSize * sizeof(xmlChar));
+ rebuf = (xmlChar *) xmlMallocAtomic(newSize * sizeof(xmlChar));
else
rebuf = (xmlChar *) xmlRealloc(buf->content,
newSize * sizeof(xmlChar));