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/HTMLparser.c b/HTMLparser.c
index 86c575f..572a750 100644
--- a/HTMLparser.c
+++ b/HTMLparser.c
@@ -2268,7 +2268,7 @@
xmlChar *buffer;
int max = len * 2;
- buffer = (xmlChar *) xmlMalloc(max * sizeof(xmlChar));
+ buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
if (buffer == NULL) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt->userData,
@@ -2333,7 +2333,7 @@
* allocate a translation buffer.
*/
buffer_size = HTML_PARSER_BUFFER_SIZE;
- buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar));
+ buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar));
if (buffer == NULL) {
xmlGenericError(xmlGenericErrorContext,
"htmlParseHTMLAttribute: malloc failed\n");
@@ -2900,7 +2900,7 @@
ctxt->instate = XML_PARSER_COMMENT;
SHRINK;
SKIP(4);
- buf = (xmlChar *) xmlMalloc(size * sizeof(xmlChar));
+ buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
if (buf == NULL) {
xmlGenericError(xmlGenericErrorContext,
"malloc of %d byte failed\n", size);
@@ -5378,7 +5378,7 @@
/* set encoding */
if (encoding) {
- content = xmlMalloc (xmlStrlen(content_line) + strlen(encoding) + 1);
+ content = xmlMallocAtomic (xmlStrlen(content_line) + strlen(encoding) + 1);
if (content) {
strcpy ((char *)content, (char *)content_line);
strcat ((char *)content, (char *)encoding);