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

memory: Deprecate xmlGcMemSetup

This commit is contained in:
Nick Wellnhofer 2024-07-16 00:35:53 +02:00
parent ff39f28bd7
commit 5d36664fc9
16 changed files with 47 additions and 41 deletions

View File

@ -2636,7 +2636,7 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
* allocate a translation buffer.
*/
buffer_size = HTML_PARSER_BUFFER_SIZE;
buffer = (xmlChar *) xmlMallocAtomic(buffer_size);
buffer = xmlMalloc(buffer_size);
if (buffer == NULL) {
htmlErrMemory(ctxt);
return(NULL);
@ -3272,7 +3272,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
target, NULL);
goto done;
}
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
htmlErrMemory(ctxt);
return;
@ -3368,7 +3368,7 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
state = ctxt->instate;
ctxt->instate = XML_PARSER_COMMENT;
SKIP(4);
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
htmlErrMemory(ctxt);
return;

2
c14n.c
View File

@ -2133,7 +2133,7 @@ xmlC11NNormalizeString(const xmlChar * input,
* allocate an translation buffer.
*/
buffer_size = 1000;
buffer = (xmlChar *) xmlMallocAtomic(buffer_size);
buffer = xmlMalloc(buffer_size);
if (buffer == NULL)
return (NULL);
out = buffer;

View File

@ -967,7 +967,7 @@ xmlLoadFileContent(const char *filename)
return (NULL);
}
size = info.st_size;
content = (xmlChar*)xmlMallocAtomic(size + 10);
content = xmlMalloc(size + 10);
if (content == NULL) {
xmlCatalogErrMemory();
close(fd);
@ -2158,7 +2158,7 @@ xmlParseSGMLCatalogPubid(const xmlChar *cur, xmlChar **id) {
} else {
stop = ' ';
}
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlCatalogErrMemory();
return(NULL);

View File

@ -112,12 +112,14 @@ XMLPUBFUN int
xmlMallocFunc *mallocFunc,
xmlReallocFunc *reallocFunc,
xmlStrdupFunc *strdupFunc);
XML_DEPRECATED
XMLPUBFUN int
xmlGcMemSetup (xmlFreeFunc freeFunc,
xmlMallocFunc mallocFunc,
xmlMallocFunc mallocAtomicFunc,
xmlReallocFunc reallocFunc,
xmlStrdupFunc strdupFunc);
XML_DEPRECATED
XMLPUBFUN int
xmlGcMemGet (xmlFreeFunc *freeFunc,
xmlMallocFunc *mallocFunc,

View File

@ -500,7 +500,7 @@ xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt)
while (ctxt->state & XML_NANO_HTTP_READ) {
if (ctxt->in == NULL) {
ctxt->in = (char *) xmlMallocAtomic(65000);
ctxt->in = xmlMalloc(65000);
if (ctxt->in == NULL) {
xmlHTTPErrMemory();
ctxt->last = -1;
@ -1441,7 +1441,7 @@ retry:
else
blen += 11;
}
bp = (char*)xmlMallocAtomic(blen);
bp = xmlMalloc(blen);
if ( bp == NULL ) {
xmlNanoHTTPFreeCtxt( ctxt );
xmlHTTPErrMemory();

View File

@ -3014,7 +3014,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefixOut) {
*/
max = len * 2;
buffer = (xmlChar *) xmlMallocAtomic(max);
buffer = xmlMalloc(max);
if (buffer == NULL) {
xmlErrMemory(ctxt);
return(NULL);
@ -3101,7 +3101,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefixOut) {
*/
max = len * 2;
buffer = (xmlChar *) xmlMallocAtomic(max);
buffer = xmlMalloc(max);
if (buffer == NULL) {
xmlErrMemory(ctxt);
xmlFree(prefix);
@ -3598,7 +3598,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
xmlChar *buffer;
int max = len * 2;
buffer = (xmlChar *) xmlMallocAtomic(max);
buffer = xmlMalloc(max);
if (buffer == NULL) {
xmlErrMemory(ctxt);
return(NULL);
@ -3681,7 +3681,7 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
xmlChar *buffer;
int max = len * 2;
buffer = (xmlChar *) xmlMallocAtomic(max);
buffer = xmlMalloc(max);
if (buffer == NULL) {
xmlErrMemory(ctxt);
return(NULL);
@ -4600,7 +4600,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
return(NULL);
}
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlErrMemory(ctxt);
return(NULL);
@ -4671,7 +4671,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, NULL);
return(NULL);
}
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlErrMemory(ctxt);
return(NULL);
@ -5109,7 +5109,7 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
if (buf == NULL) {
len = 0;
size = XML_PARSER_BUFFER_SIZE;
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlErrMemory(ctxt);
return;
@ -5273,7 +5273,7 @@ get_more:
size = nbchar + 1;
else
size = XML_PARSER_BUFFER_SIZE + nbchar;
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlErrMemory(ctxt);
return;
@ -5517,7 +5517,7 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
target, NULL);
return;
}
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlErrMemory(ctxt);
return;
@ -9614,7 +9614,7 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
}
NEXTL(sl);
cur = xmlCurrentCharRecover(ctxt, &l);
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlErrMemory(ctxt);
goto out;
@ -10019,7 +10019,7 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
int size = 10;
xmlChar cur;
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlErrMemory(ctxt);
return(NULL);
@ -10134,7 +10134,7 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
cur = CUR;
if (((cur >= 'a') && (cur <= 'z')) ||
((cur >= 'A') && (cur <= 'Z'))) {
buf = (xmlChar *) xmlMallocAtomic(size);
buf = xmlMalloc(size);
if (buf == NULL) {
xmlErrMemory(ctxt);
return(NULL);

View File

@ -8426,7 +8426,7 @@ xmlRelaxNGNormalize(xmlRelaxNGValidCtxtPtr ctxt, const xmlChar * str)
tmp++;
len = tmp - str;
ret = (xmlChar *) xmlMallocAtomic(len + 1);
ret = xmlMalloc(len + 1);
if (ret == NULL) {
xmlRngVErrMemory(ctxt);
return (NULL);

6
tree.c
View File

@ -186,7 +186,7 @@ xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix,
lenp = strlen((char *) prefix);
if ((memory == NULL) || (len < lenn + lenp + 2)) {
ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
ret = xmlMalloc(lenn + lenp + 2);
if (ret == NULL)
return(NULL);
} else {
@ -4736,10 +4736,10 @@ xmlGetNodePath(const xmlNode *node)
return (NULL);
buf_len = 500;
buffer = (xmlChar *) xmlMallocAtomic(buf_len);
buffer = xmlMalloc(buf_len);
if (buffer == NULL)
return (NULL);
buf = (xmlChar *) xmlMallocAtomic(buf_len);
buf = xmlMalloc(buf_len);
if (buf == NULL) {
xmlFree(buffer);
return (NULL);

8
uri.c
View File

@ -1132,7 +1132,7 @@ xmlSaveUri(xmlURIPtr uri) {
max = 80;
ret = (xmlChar *) xmlMallocAtomic(max + 1);
ret = xmlMalloc(max + 1);
if (ret == NULL)
return(NULL);
len = 0;
@ -1625,7 +1625,7 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
if (len < 0) return(NULL);
if (target == NULL) {
ret = (char *) xmlMallocAtomic(len + 1);
ret = xmlMalloc(len + 1);
if (ret == NULL)
return(NULL);
} else
@ -1687,7 +1687,7 @@ xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) {
len = xmlStrlen(str);
len += 20;
ret = (xmlChar *) xmlMallocAtomic(len);
ret = xmlMalloc(len);
if (ret == NULL)
return(NULL);
in = (const xmlChar *) str;
@ -2270,7 +2270,7 @@ xmlBuildURISafe(const xmlChar *URI, const xmlChar *base, xmlChar **valPtr) {
len += strlen(ref->path);
if (bas->path != NULL)
len += strlen(bas->path);
res->path = (char *) xmlMallocAtomic(len);
res->path = xmlMalloc(len);
if (res->path == NULL)
goto done;
res->path[0] = 0;

View File

@ -497,6 +497,8 @@ xmlMemGet(xmlFreeFunc *freeFunc, xmlMallocFunc *mallocFunc,
* @reallocFunc: the realloc() function to use
* @strdupFunc: the strdup() function to use
*
* DEPRECATED: Use xmlMemSetup.
*
* Override the default memory access functions with a new set
* This has to be called before any other libxml routines !
* The mallocAtomicFunc is specialized for atomic block
@ -537,6 +539,8 @@ xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
* @reallocFunc: place to save the realloc() function in use
* @strdupFunc: place to save the strdup() function in use
*
* DEPRECATED: xmlMemGet.
*
* Provides the memory access functions set currently in use
* The mallocAtomicFunc is specialized for atomic block
* allocations (i.e. of areas useful for garbage collected memory allocators

View File

@ -4029,7 +4029,7 @@ xmlRegExecPushString2(xmlRegExecCtxtPtr exec, const xmlChar *value,
lenp = strlen((char *) value);
if (150 < lenn + lenp + 2) {
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
str = xmlMalloc(lenn + lenp + 2);
if (str == NULL) {
exec->status = XML_REGEXP_OUT_OF_MEMORY;
return(-1);
@ -5569,7 +5569,7 @@ xmlAutomataNewTransition2(xmlAutomataPtr am, xmlAutomataStatePtr from,
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
str = xmlMalloc(lenn + lenp + 2);
if (str == NULL) {
xmlRegFreeAtom(atom);
return(NULL);
@ -5631,7 +5631,7 @@ xmlAutomataNewNegTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
str = xmlMalloc(lenn + lenp + 2);
if (str == NULL) {
xmlRegFreeAtom(atom);
return(NULL);
@ -5703,7 +5703,7 @@ xmlAutomataNewCountTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
str = xmlMalloc(lenn + lenp + 2);
if (str == NULL)
goto error;
memcpy(&str[0], token, lenp);
@ -5876,7 +5876,7 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
lenn = strlen((char *) token2);
lenp = strlen((char *) token);
str = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
str = xmlMalloc(lenn + lenp + 2);
if (str == NULL)
goto error;
memcpy(&str[0], token, lenp);

View File

@ -27292,7 +27292,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
* we are forced to work around it.
*/
valueLen = attributes[j+4] - attributes[j+3];
value = xmlMallocAtomic(valueLen + 1);
value = xmlMalloc(valueLen + 1);
if (value == NULL) {
xmlSchemaVErrMemory(vctxt);
goto internal_error;

View File

@ -3426,7 +3426,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
if (v == NULL)
goto error;
base =
(xmlChar *) xmlMallocAtomic(i + pad + 1);
xmlMalloc(i + pad + 1);
if (base == NULL) {
xmlSchemaTypeErrMemory();
xmlFree(v);

View File

@ -54,7 +54,7 @@ xmlStrndup(const xmlChar *cur, int len) {
xmlChar *ret;
if ((cur == NULL) || (len < 0)) return(NULL);
ret = (xmlChar *) xmlMallocAtomic((size_t) len + 1);
ret = xmlMalloc((size_t) len + 1);
if (ret == NULL) {
return(NULL);
}
@ -98,7 +98,7 @@ xmlCharStrndup(const char *cur, int len) {
xmlChar *ret;
if ((cur == NULL) || (len < 0)) return(NULL);
ret = (xmlChar *) xmlMallocAtomic((size_t) len + 1);
ret = xmlMalloc((size_t) len + 1);
if (ret == NULL) {
return(NULL);
}
@ -1022,7 +1022,7 @@ xmlUTF8Strndup(const xmlChar *utf, int len) {
if ((utf == NULL) || (len < 0)) return(NULL);
i = xmlUTF8Strsize(utf, len);
ret = (xmlChar *) xmlMallocAtomic((size_t) i + 1);
ret = xmlMalloc((size_t) i + 1);
if (ret == NULL) {
return(NULL);
}
@ -1178,7 +1178,7 @@ xmlEscapeFormatString(xmlChar **msg)
if ((count > INT_MAX) || (msgLen > INT_MAX - count))
return(NULL);
resultLen = msgLen + count + 1;
result = (xmlChar *) xmlMallocAtomic(resultLen);
result = xmlMalloc(resultLen);
if (result == NULL) {
/* Clear *msg to prevent format string vulnerabilities in
out-of-memory situations. */

View File

@ -8644,7 +8644,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
if (len > XML_MAX_NAME_LENGTH) {
XP_ERRORNULL(XPATH_EXPR_ERROR);
}
buffer = (xmlChar *) xmlMallocAtomic(max);
buffer = xmlMalloc(max);
if (buffer == NULL) {
xmlXPathPErrMemory(ctxt);
return(NULL);

View File

@ -267,7 +267,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
len = xmlStrlen(ctxt->cur);
len++;
buffer = (xmlChar *) xmlMallocAtomic(len);
buffer = xmlMalloc(len);
if (buffer == NULL) {
xmlXPathPErrMemory(ctxt);
xmlFree(name);