mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-30 22:43:14 +03:00
converting the tree module too created a simpler internal error reporting
* tree.c: converting the tree module too * error.c include/libxml/xmlerror.h: created a simpler internal error reporting function. Daniel
This commit is contained in:
@ -1,3 +1,9 @@
|
|||||||
|
Wed Oct 8 01:09:05 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* tree.c: converting the tree module too
|
||||||
|
* error.c include/libxml/xmlerror.h: created a simpler internal
|
||||||
|
error reporting function.
|
||||||
|
|
||||||
Tue Oct 7 23:19:39 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
Tue Oct 7 23:19:39 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* error.c include/libxml/xmlerror.h include/libxml/xpath.h
|
* error.c include/libxml/xmlerror.h include/libxml/xpath.h
|
||||||
|
30
error.c
30
error.c
@ -517,6 +517,36 @@ __xmlRaiseError(xmlGenericErrorFunc channel, void *data, void *ctx,
|
|||||||
channel(data, "%s", str);
|
channel(data, "%s", str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __xmlSimpleError:
|
||||||
|
* @domain: where the error comes from
|
||||||
|
* @code: the error code
|
||||||
|
* @node: the context node
|
||||||
|
* @extra: extra informations
|
||||||
|
*
|
||||||
|
* Handle an out of memory condition
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
__xmlSimpleError(int domain, int code, xmlNodePtr node,
|
||||||
|
const char *msg, const char *extra)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (code == XML_ERR_NO_MEMORY) {
|
||||||
|
if (extra)
|
||||||
|
__xmlRaiseError(NULL, NULL, NULL, node, domain,
|
||||||
|
XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra,
|
||||||
|
NULL, NULL, 0, 0,
|
||||||
|
"Memory allocation failed : %s\n", extra);
|
||||||
|
else
|
||||||
|
__xmlRaiseError(NULL, NULL, NULL, node, domain,
|
||||||
|
XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL,
|
||||||
|
NULL, NULL, 0, 0, "Memory allocation failed\n");
|
||||||
|
} else {
|
||||||
|
__xmlRaiseError(NULL, NULL, NULL, node, domain,
|
||||||
|
code, XML_ERR_ERROR, NULL, 0, extra,
|
||||||
|
NULL, NULL, 0, 0, msg, extra);
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* xmlParserError:
|
* xmlParserError:
|
||||||
* @ctx: an XML parser context
|
* @ctx: an XML parser context
|
||||||
|
@ -27,6 +27,7 @@ typedef enum {
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
XML_FROM_NONE = 0,
|
XML_FROM_NONE = 0,
|
||||||
XML_FROM_PARSER, /* The XML parser */
|
XML_FROM_PARSER, /* The XML parser */
|
||||||
|
XML_FROM_TREE, /* The tree module */
|
||||||
XML_FROM_NAMESPACE, /* The XML Namespace module */
|
XML_FROM_NAMESPACE, /* The XML Namespace module */
|
||||||
XML_FROM_DTD, /* The XML DTD validation */
|
XML_FROM_DTD, /* The XML DTD validation */
|
||||||
XML_FROM_HTML, /* The HTML parser */
|
XML_FROM_HTML, /* The HTML parser */
|
||||||
@ -397,7 +398,13 @@ typedef enum {
|
|||||||
XML_XPTR_SUB_RESOURCE_ERROR,
|
XML_XPTR_SUB_RESOURCE_ERROR,
|
||||||
XML_XPATH_UNDEF_PREFIX_ERROR,
|
XML_XPATH_UNDEF_PREFIX_ERROR,
|
||||||
XML_XPATH_ENCODING_ERROR,
|
XML_XPATH_ENCODING_ERROR,
|
||||||
XML_XPATH_INVALID_CHAR_ERROR
|
XML_XPATH_INVALID_CHAR_ERROR,
|
||||||
|
XML_TREE_INVALID_HEX = 1300,
|
||||||
|
XML_TREE_INVALID_DEC,
|
||||||
|
XML_TREE_UNTERMINATED_ENTITY,
|
||||||
|
XML_SAVE_NOT_UTF8 = 1400,
|
||||||
|
XML_SAVE_CHAR_INVALID,
|
||||||
|
XML_SAVE_UNKNOWN_ENCODING
|
||||||
} xmlParserErrors;
|
} xmlParserErrors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -495,6 +502,12 @@ XMLPUBFUN void XMLCALL
|
|||||||
int int2,
|
int int2,
|
||||||
const char *msg,
|
const char *msg,
|
||||||
...);
|
...);
|
||||||
|
XMLPUBFUN void XMLCALL
|
||||||
|
__xmlSimpleError (int domain,
|
||||||
|
int code,
|
||||||
|
xmlNodePtr node,
|
||||||
|
const char *msg,
|
||||||
|
const char *extra);
|
||||||
#endif
|
#endif
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
300
tree.c
300
tree.c
@ -42,6 +42,51 @@ int __xmlRegisterCallbacks = 0;
|
|||||||
|
|
||||||
xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
|
xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
|
||||||
|
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* Tree memory error handler *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
/**
|
||||||
|
* xmlTreeErrMemory:
|
||||||
|
* @extra: extra informations
|
||||||
|
*
|
||||||
|
* Handle an out of memory condition
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
xmlTreeErrMemory(const char *extra)
|
||||||
|
{
|
||||||
|
__xmlSimpleError(XML_FROM_TREE, XML_ERR_NO_MEMORY, NULL, NULL, extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlTreeErr:
|
||||||
|
* @code: the error number
|
||||||
|
* @extra: extra informations
|
||||||
|
*
|
||||||
|
* Handle an out of memory condition
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
xmlTreeErr(int code, xmlNodePtr node, const char *extra)
|
||||||
|
{
|
||||||
|
const char *msg = NULL;
|
||||||
|
|
||||||
|
switch(code) {
|
||||||
|
case XML_TREE_INVALID_HEX:
|
||||||
|
msg = "invalid hexadecimal character value";
|
||||||
|
break;
|
||||||
|
case XML_TREE_INVALID_DEC:
|
||||||
|
msg = "invalid decimal character value";
|
||||||
|
break;
|
||||||
|
case XML_TREE_UNTERMINATED_ENTITY:
|
||||||
|
msg = "unterminated entity reference %15s";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
msg = "unexpected error number";
|
||||||
|
}
|
||||||
|
__xmlSimpleError(XML_FROM_TREE, code, node, msg, extra);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* A few static variables and macros *
|
* A few static variables and macros *
|
||||||
@ -161,7 +206,10 @@ xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix,
|
|||||||
|
|
||||||
if ((memory == NULL) || (len < lenn + lenp + 2)) {
|
if ((memory == NULL) || (len < lenn + lenp + 2)) {
|
||||||
ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
|
ret = (xmlChar *) xmlMallocAtomic(lenn + lenp + 2);
|
||||||
if (ret == NULL) return(NULL);
|
if (ret == NULL) {
|
||||||
|
xmlTreeErrMemory("building QName");
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
ret = memory;
|
ret = memory;
|
||||||
}
|
}
|
||||||
@ -220,14 +268,12 @@ xmlSplitQName2(const xmlChar *name, xmlChar **prefix) {
|
|||||||
|
|
||||||
*prefix = xmlStrndup(name, len);
|
*prefix = xmlStrndup(name, len);
|
||||||
if (*prefix == NULL) {
|
if (*prefix == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("QName split");
|
||||||
"xmlSplitQName2 : out of memory!\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret = xmlStrdup(&name[len + 1]);
|
ret = xmlStrdup(&name[len + 1]);
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("QName split");
|
||||||
"xmlSplitQName2 : out of memory!\n");
|
|
||||||
if (*prefix != NULL) {
|
if (*prefix != NULL) {
|
||||||
xmlFree(*prefix);
|
xmlFree(*prefix);
|
||||||
*prefix = NULL;
|
*prefix = NULL;
|
||||||
@ -650,8 +696,7 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building namespace");
|
||||||
"xmlNewNs : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNs));
|
memset(cur, 0, sizeof(xmlNs));
|
||||||
@ -785,8 +830,7 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
|
|||||||
*/
|
*/
|
||||||
cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd));
|
cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building DTD");
|
||||||
"xmlNewDtd : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0 , sizeof(xmlDtd));
|
memset(cur, 0 , sizeof(xmlDtd));
|
||||||
@ -860,8 +904,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
|
|||||||
*/
|
*/
|
||||||
cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd));
|
cur = (xmlDtdPtr) xmlMalloc(sizeof(xmlDtd));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building internal subset");
|
||||||
"xmlCreateIntSubset : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlDtd));
|
memset(cur, 0, sizeof(xmlDtd));
|
||||||
@ -1002,8 +1045,7 @@ xmlNewDoc(const xmlChar *version) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc));
|
cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building doc");
|
||||||
"xmlNewDoc : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlDoc));
|
memset(cur, 0, sizeof(xmlDoc));
|
||||||
@ -1141,8 +1183,8 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
|
|||||||
else if ((tmp >= 'A') && (tmp <= 'F'))
|
else if ((tmp >= 'A') && (tmp <= 'F'))
|
||||||
charval = charval * 16 + (tmp - 'A') + 10;
|
charval = charval * 16 + (tmp - 'A') + 10;
|
||||||
else {
|
else {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErr(XML_TREE_INVALID_HEX, (xmlNodePtr) doc,
|
||||||
"xmlStringGetNodeList: invalid hexadecimal charvalue\n");
|
NULL);
|
||||||
charval = 0;
|
charval = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1165,8 +1207,8 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
|
|||||||
if ((tmp >= '0') && (tmp <= '9'))
|
if ((tmp >= '0') && (tmp <= '9'))
|
||||||
charval = charval * 10 + (tmp - '0');
|
charval = charval * 10 + (tmp - '0');
|
||||||
else {
|
else {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc,
|
||||||
"xmlStringGetNodeList: invalid decimal charvalue\n");
|
NULL);
|
||||||
charval = 0;
|
charval = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1187,10 +1229,8 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
|
|||||||
q = cur;
|
q = cur;
|
||||||
while ((cur < end) && (*cur != 0) && (*cur != ';')) cur++;
|
while ((cur < end) && (*cur != 0) && (*cur != ';')) cur++;
|
||||||
if ((cur >= end) || (*cur == 0)) {
|
if ((cur >= end) || (*cur == 0)) {
|
||||||
#ifdef DEBUG_TREE
|
xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY, (xmlNodePtr) doc,
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
(const char *) q);
|
||||||
"xmlStringGetNodeList: unterminated entity %30s\n", q);
|
|
||||||
#endif
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
if (cur != q) {
|
if (cur != q) {
|
||||||
@ -1336,8 +1376,8 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
|||||||
else if ((tmp >= 'A') && (tmp <= 'F'))
|
else if ((tmp >= 'A') && (tmp <= 'F'))
|
||||||
charval = charval * 16 + (tmp - 'A') + 10;
|
charval = charval * 16 + (tmp - 'A') + 10;
|
||||||
else {
|
else {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErr(XML_TREE_INVALID_HEX, (xmlNodePtr) doc,
|
||||||
"xmlStringGetNodeList: invalid hexadecimal charvalue\n");
|
NULL);
|
||||||
charval = 0;
|
charval = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1354,8 +1394,8 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
|||||||
if ((tmp >= '0') && (tmp <= '9'))
|
if ((tmp >= '0') && (tmp <= '9'))
|
||||||
charval = charval * 10 + (tmp - '0');
|
charval = charval * 10 + (tmp - '0');
|
||||||
else {
|
else {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc,
|
||||||
"xmlStringGetNodeList: invalid decimal charvalue\n");
|
NULL);
|
||||||
charval = 0;
|
charval = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1373,10 +1413,8 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
|
|||||||
q = cur;
|
q = cur;
|
||||||
while ((*cur != 0) && (*cur != ';')) cur++;
|
while ((*cur != 0) && (*cur != ';')) cur++;
|
||||||
if (*cur == 0) {
|
if (*cur == 0) {
|
||||||
#ifdef DEBUG_TREE
|
xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY,
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
(xmlNodePtr) doc, (const char *) q);
|
||||||
"xmlStringGetNodeList: unterminated entity %30s\n", q);
|
|
||||||
#endif
|
|
||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
if (cur != q) {
|
if (cur != q) {
|
||||||
@ -1661,8 +1699,7 @@ xmlNewProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
|
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building attribute");
|
||||||
"xmlNewProp : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlAttr));
|
memset(cur, 0, sizeof(xmlAttr));
|
||||||
@ -1742,8 +1779,7 @@ xmlNewNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
|
|||||||
*/
|
*/
|
||||||
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
|
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building attribute");
|
||||||
"xmlNewNsProp : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlAttr));
|
memset(cur, 0, sizeof(xmlAttr));
|
||||||
@ -1822,8 +1858,7 @@ xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
|
|||||||
*/
|
*/
|
||||||
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
|
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building attribute");
|
||||||
"xmlNewNsPropEatName : malloc failed\n");
|
|
||||||
xmlFree(name);
|
xmlFree(name);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -1900,8 +1935,7 @@ xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
|
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building attribute");
|
||||||
"xmlNewDocProp : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlAttr));
|
memset(cur, 0, sizeof(xmlAttr));
|
||||||
@ -2050,8 +2084,7 @@ xmlNewPI(const xmlChar *name, const xmlChar *content) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building PI");
|
||||||
"xmlNewPI : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -2093,8 +2126,7 @@ xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building node");
|
||||||
"xmlNewNode : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -2134,8 +2166,7 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building node");
|
||||||
"xmlNewNode : malloc failed\n");
|
|
||||||
xmlFree(name);
|
xmlFree(name);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -2260,8 +2291,7 @@ xmlNewDocFragment(xmlDocPtr doc) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building fragment");
|
||||||
"xmlNewDocFragment : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -2291,8 +2321,7 @@ xmlNewText(const xmlChar *content) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building text");
|
||||||
"xmlNewText : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -2389,8 +2418,7 @@ xmlNewCharRef(xmlDocPtr doc, const xmlChar *name) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building character reference");
|
||||||
"xmlNewCharRef : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -2431,8 +2459,7 @@ xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building reference");
|
||||||
"xmlNewReference : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -2501,8 +2528,7 @@ xmlNewTextLen(const xmlChar *content, int len) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building text");
|
||||||
"xmlNewTextLen : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -2553,8 +2579,7 @@ xmlNewComment(const xmlChar *content) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building comment");
|
||||||
"xmlNewComment : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -2588,8 +2613,7 @@ xmlNewCDataBlock(xmlDocPtr doc, const xmlChar *content, int len) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("building CDATA");
|
||||||
"xmlNewCDataBlock : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNode));
|
memset(cur, 0, sizeof(xmlNode));
|
||||||
@ -3700,8 +3724,7 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
|
|||||||
*/
|
*/
|
||||||
ret = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
ret = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("copying node");
|
||||||
"xmlStaticCopyNode : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(ret, 0, sizeof(xmlNode));
|
memset(ret, 0, sizeof(xmlNode));
|
||||||
@ -4088,10 +4111,13 @@ xmlGetNodePath(xmlNodePtr node)
|
|||||||
|
|
||||||
buf_len = 500;
|
buf_len = 500;
|
||||||
buffer = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar));
|
buffer = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar));
|
||||||
if (buffer == NULL)
|
if (buffer == NULL) {
|
||||||
|
xmlTreeErrMemory("getting node path");
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
}
|
||||||
buf = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar));
|
buf = (xmlChar *) xmlMallocAtomic(buf_len * sizeof(xmlChar));
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
|
xmlTreeErrMemory("getting node path");
|
||||||
xmlFree(buffer);
|
xmlFree(buffer);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
@ -4243,6 +4269,7 @@ xmlGetNodePath(xmlNodePtr node)
|
|||||||
2 * buf_len + xmlStrlen(buffer) + sizeof(nametemp) + 20;
|
2 * buf_len + xmlStrlen(buffer) + sizeof(nametemp) + 20;
|
||||||
temp = (xmlChar *) xmlRealloc(buffer, buf_len);
|
temp = (xmlChar *) xmlRealloc(buffer, buf_len);
|
||||||
if (temp == NULL) {
|
if (temp == NULL) {
|
||||||
|
xmlTreeErrMemory("getting node path");
|
||||||
xmlFree(buf);
|
xmlFree(buf);
|
||||||
xmlFree(buffer);
|
xmlFree(buffer);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -4250,6 +4277,7 @@ xmlGetNodePath(xmlNodePtr node)
|
|||||||
buffer = temp;
|
buffer = temp;
|
||||||
temp = (xmlChar *) xmlRealloc(buf, buf_len);
|
temp = (xmlChar *) xmlRealloc(buf, buf_len);
|
||||||
if (temp == NULL) {
|
if (temp == NULL) {
|
||||||
|
xmlTreeErrMemory("getting node path");
|
||||||
xmlFree(buf);
|
xmlFree(buf);
|
||||||
xmlFree(buffer);
|
xmlFree(buffer);
|
||||||
return (NULL);
|
return (NULL);
|
||||||
@ -5144,8 +5172,7 @@ xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node)
|
|||||||
(xmlNsPtr *) xmlMalloc((maxns + 1) *
|
(xmlNsPtr *) xmlMalloc((maxns + 1) *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("getting namespace list");
|
||||||
"xmlGetNsList : out of memory!\n");
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
ret[nbns] = NULL;
|
ret[nbns] = NULL;
|
||||||
@ -5163,8 +5190,7 @@ xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node)
|
|||||||
1) *
|
1) *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("getting namespace list");
|
||||||
"xmlGetNsList : realloc failed!\n");
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5212,8 +5238,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("searching namespace");
|
||||||
"xmlSearchNs : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNs));
|
memset(cur, 0, sizeof(xmlNs));
|
||||||
@ -5230,8 +5255,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
|
|||||||
*/
|
*/
|
||||||
doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
||||||
if (doc->oldNs == NULL) {
|
if (doc->oldNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("searching namespace");
|
||||||
"xmlSearchNs : malloc failed\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
memset(doc->oldNs, 0, sizeof(xmlNs));
|
memset(doc->oldNs, 0, sizeof(xmlNs));
|
||||||
@ -5348,8 +5372,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
|
|||||||
*/
|
*/
|
||||||
cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
cur = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
||||||
if (cur == NULL) {
|
if (cur == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("searching namespace");
|
||||||
"xmlSearchNs : malloc failed\n");
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
memset(cur, 0, sizeof(xmlNs));
|
memset(cur, 0, sizeof(xmlNs));
|
||||||
@ -5366,8 +5389,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
|
|||||||
*/
|
*/
|
||||||
doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
doc->oldNs = (xmlNsPtr) xmlMalloc(sizeof(xmlNs));
|
||||||
if (doc->oldNs == NULL) {
|
if (doc->oldNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("searching namespace");
|
||||||
"xmlSearchNsByHref : malloc failed\n");
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
memset(doc->oldNs, 0, sizeof(xmlNs));
|
memset(doc->oldNs, 0, sizeof(xmlNs));
|
||||||
@ -5513,15 +5535,13 @@ xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) {
|
|||||||
oldNs = (xmlNsPtr *) xmlMalloc(sizeCache *
|
oldNs = (xmlNsPtr *) xmlMalloc(sizeCache *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (oldNs == NULL) {
|
if (oldNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("fixing namespaces");
|
||||||
"xmlReconciliateNs : memory pbm\n");
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
newNs = (xmlNsPtr *) xmlMalloc(sizeCache *
|
newNs = (xmlNsPtr *) xmlMalloc(sizeCache *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (newNs == NULL) {
|
if (newNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("fixing namespaces");
|
||||||
"xmlReconciliateNs : memory pbm\n");
|
|
||||||
xmlFree(oldNs);
|
xmlFree(oldNs);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -5546,16 +5566,14 @@ xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) {
|
|||||||
oldNs = (xmlNsPtr *) xmlRealloc(oldNs, sizeCache *
|
oldNs = (xmlNsPtr *) xmlRealloc(oldNs, sizeCache *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (oldNs == NULL) {
|
if (oldNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("fixing namespaces");
|
||||||
"xmlReconciliateNs : memory pbm\n");
|
|
||||||
xmlFree(newNs);
|
xmlFree(newNs);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
newNs = (xmlNsPtr *) xmlRealloc(newNs, sizeCache *
|
newNs = (xmlNsPtr *) xmlRealloc(newNs, sizeCache *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (newNs == NULL) {
|
if (newNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("fixing namespaces");
|
||||||
"xmlReconciliateNs : memory pbm\n");
|
|
||||||
xmlFree(oldNs);
|
xmlFree(oldNs);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -5580,15 +5598,13 @@ xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) {
|
|||||||
oldNs = (xmlNsPtr *) xmlMalloc(sizeCache *
|
oldNs = (xmlNsPtr *) xmlMalloc(sizeCache *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (oldNs == NULL) {
|
if (oldNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("fixing namespaces");
|
||||||
"xmlReconciliateNs : memory pbm\n");
|
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
newNs = (xmlNsPtr *) xmlMalloc(sizeCache *
|
newNs = (xmlNsPtr *) xmlMalloc(sizeCache *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (newNs == NULL) {
|
if (newNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("fixing namespaces");
|
||||||
"xmlReconciliateNs : memory pbm\n");
|
|
||||||
xmlFree(oldNs);
|
xmlFree(oldNs);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -5613,16 +5629,14 @@ xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) {
|
|||||||
oldNs = (xmlNsPtr *) xmlRealloc(oldNs, sizeCache *
|
oldNs = (xmlNsPtr *) xmlRealloc(oldNs, sizeCache *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (oldNs == NULL) {
|
if (oldNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("fixing namespaces");
|
||||||
"xmlReconciliateNs : memory pbm\n");
|
|
||||||
xmlFree(newNs);
|
xmlFree(newNs);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
newNs = (xmlNsPtr *) xmlRealloc(newNs, sizeCache *
|
newNs = (xmlNsPtr *) xmlRealloc(newNs, sizeCache *
|
||||||
sizeof(xmlNsPtr));
|
sizeof(xmlNsPtr));
|
||||||
if (newNs == NULL) {
|
if (newNs == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("fixing namespaces");
|
||||||
"xmlReconciliateNs : memory pbm\n");
|
|
||||||
xmlFree(oldNs);
|
xmlFree(oldNs);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
@ -6272,8 +6286,7 @@ xmlBufferCreate(void) {
|
|||||||
|
|
||||||
ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer));
|
ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("creating buffer");
|
||||||
"xmlBufferCreate : out of memory!\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret->use = 0;
|
ret->use = 0;
|
||||||
@ -6281,8 +6294,7 @@ xmlBufferCreate(void) {
|
|||||||
ret->alloc = xmlBufferAllocScheme;
|
ret->alloc = xmlBufferAllocScheme;
|
||||||
ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
|
ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
|
||||||
if (ret->content == NULL) {
|
if (ret->content == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("creating buffer");
|
||||||
"xmlBufferCreate : out of memory!\n");
|
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -6303,8 +6315,7 @@ xmlBufferCreateSize(size_t size) {
|
|||||||
|
|
||||||
ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer));
|
ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("creating buffer");
|
||||||
"xmlBufferCreate : out of memory!\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret->use = 0;
|
ret->use = 0;
|
||||||
@ -6313,8 +6324,7 @@ xmlBufferCreateSize(size_t size) {
|
|||||||
if (ret->size){
|
if (ret->size){
|
||||||
ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
|
ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
|
||||||
if (ret->content == NULL) {
|
if (ret->content == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("creating buffer");
|
||||||
"xmlBufferCreate : out of memory!\n");
|
|
||||||
xmlFree(ret);
|
xmlFree(ret);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@ -6344,8 +6354,7 @@ xmlBufferCreateStatic(void *mem, size_t size) {
|
|||||||
|
|
||||||
ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer));
|
ret = (xmlBufferPtr) xmlMalloc(sizeof(xmlBuffer));
|
||||||
if (ret == NULL) {
|
if (ret == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("creating buffer");
|
||||||
"xmlBufferCreate : out of memory!\n");
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret->use = size;
|
ret->use = size;
|
||||||
@ -6462,7 +6471,10 @@ xmlBufferGrow(xmlBufferPtr buf, unsigned int len) {
|
|||||||
size = buf->use + len + 100;
|
size = buf->use + len + 100;
|
||||||
|
|
||||||
newbuf = (xmlChar *) xmlRealloc(buf->content, size);
|
newbuf = (xmlChar *) xmlRealloc(buf->content, size);
|
||||||
if (newbuf == NULL) return(-1);
|
if (newbuf == NULL) {
|
||||||
|
xmlTreeErrMemory("growing buffer");
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
buf->content = newbuf;
|
buf->content = newbuf;
|
||||||
buf->size = size;
|
buf->size = size;
|
||||||
return(buf->size - buf->use);
|
return(buf->size - buf->use);
|
||||||
@ -6592,8 +6604,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
|
|||||||
rebuf[buf->use] = 0;
|
rebuf[buf->use] = 0;
|
||||||
}
|
}
|
||||||
if (rebuf == NULL) {
|
if (rebuf == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("growing buffer");
|
||||||
"xmlBufferResize : out of memory!\n");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
buf->content = rebuf;
|
buf->content = rebuf;
|
||||||
@ -6640,8 +6651,7 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
|
|||||||
needSize = buf->use + len + 2;
|
needSize = buf->use + len + 2;
|
||||||
if (needSize > buf->size){
|
if (needSize > buf->size){
|
||||||
if (!xmlBufferResize(buf, needSize)){
|
if (!xmlBufferResize(buf, needSize)){
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("growing buffer");
|
||||||
"xmlBufferAdd : out of memory!\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6689,8 +6699,7 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
|
|||||||
needSize = buf->use + len + 2;
|
needSize = buf->use + len + 2;
|
||||||
if (needSize > buf->size){
|
if (needSize > buf->size){
|
||||||
if (!xmlBufferResize(buf, needSize)){
|
if (!xmlBufferResize(buf, needSize)){
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("growing buffer");
|
||||||
"xmlBufferAddHead : out of memory!\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6737,8 +6746,7 @@ xmlBufferCCat(xmlBufferPtr buf, const char *str) {
|
|||||||
for (cur = str;*cur != 0;cur++) {
|
for (cur = str;*cur != 0;cur++) {
|
||||||
if (buf->use + 10 >= buf->size) {
|
if (buf->use + 10 >= buf->size) {
|
||||||
if (!xmlBufferResize(buf, buf->use+10)){
|
if (!xmlBufferResize(buf, buf->use+10)){
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlTreeErrMemory("growing buffer");
|
||||||
"xmlBufferCCat : out of memory!\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -6827,6 +6835,51 @@ xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) {
|
|||||||
|
|
||||||
|
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
|
/************************************************************************
|
||||||
|
* *
|
||||||
|
* Output memory error handler *
|
||||||
|
* *
|
||||||
|
************************************************************************/
|
||||||
|
/**
|
||||||
|
* xmlSaveErrMemory:
|
||||||
|
* @extra: extra informations
|
||||||
|
*
|
||||||
|
* Handle an out of memory condition
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
xmlSaveErrMemory(const char *extra)
|
||||||
|
{
|
||||||
|
__xmlSimpleError(XML_FROM_OUTPUT, XML_ERR_NO_MEMORY, NULL, NULL, extra);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlSaveErr:
|
||||||
|
* @code: the error number
|
||||||
|
* @node: the location of the error.
|
||||||
|
* @extra: extra informations
|
||||||
|
*
|
||||||
|
* Handle an out of memory condition
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
xmlSaveErr(int code, xmlNodePtr node, const char *extra)
|
||||||
|
{
|
||||||
|
const char *msg = NULL;
|
||||||
|
|
||||||
|
switch(code) {
|
||||||
|
case XML_SAVE_NOT_UTF8:
|
||||||
|
msg = "string is not in UTF-8";
|
||||||
|
break;
|
||||||
|
case XML_SAVE_CHAR_INVALID:
|
||||||
|
msg = "invalid character value";
|
||||||
|
break;
|
||||||
|
case XML_SAVE_UNKNOWN_ENCODING:
|
||||||
|
msg = "unknown encoding %s";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
msg = "unexpected error number";
|
||||||
|
}
|
||||||
|
__xmlSimpleError(XML_FROM_TREE, code, node, msg, extra);
|
||||||
|
}
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Dumping XML tree content to a simple buffer *
|
* Dumping XML tree content to a simple buffer *
|
||||||
@ -6915,8 +6968,8 @@ xmlAttrSerializeContent(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr attr)
|
|||||||
if (base != cur)
|
if (base != cur)
|
||||||
xmlBufferAdd(buf, base, cur - base);
|
xmlBufferAdd(buf, base, cur - base);
|
||||||
if (*cur < 0xC0) {
|
if (*cur < 0xC0) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlSaveErr(XML_SAVE_NOT_UTF8, (xmlNodePtr) attr,
|
||||||
"xmlAttrSerializeContent : input not UTF-8\n");
|
NULL);
|
||||||
if (doc != NULL)
|
if (doc != NULL)
|
||||||
doc->encoding =
|
doc->encoding =
|
||||||
xmlStrdup(BAD_CAST "ISO-8859-1");
|
xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||||
@ -6949,8 +7002,8 @@ xmlAttrSerializeContent(xmlBufferPtr buf, xmlDocPtr doc, xmlAttrPtr attr)
|
|||||||
l = 4;
|
l = 4;
|
||||||
}
|
}
|
||||||
if ((l == 1) || (!IS_CHAR(val))) {
|
if ((l == 1) || (!IS_CHAR(val))) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlSaveErr(XML_SAVE_CHAR_INVALID, (xmlNodePtr) attr,
|
||||||
"xmlAttrSerializeContent : char out of range\n");
|
NULL);
|
||||||
if (doc != NULL)
|
if (doc != NULL)
|
||||||
doc->encoding =
|
doc->encoding =
|
||||||
xmlStrdup(BAD_CAST "ISO-8859-1");
|
xmlStrdup(BAD_CAST "ISO-8859-1");
|
||||||
@ -7031,8 +7084,7 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
|
|||||||
}
|
}
|
||||||
outbuf = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
outbuf = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
|
||||||
if (outbuf == NULL) {
|
if (outbuf == NULL) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlSaveErrMemory("creating buffer");
|
||||||
"xmlNodeDump: out of memory!\n");
|
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
memset(outbuf, 0, (size_t) sizeof(xmlOutputBuffer));
|
memset(outbuf, 0, (size_t) sizeof(xmlOutputBuffer));
|
||||||
@ -7086,8 +7138,7 @@ xmlElemDump(FILE * f, xmlDocPtr doc, xmlNodePtr cur)
|
|||||||
#ifdef LIBXML_HTML_ENABLED
|
#ifdef LIBXML_HTML_ENABLED
|
||||||
htmlNodeDumpOutput(outbuf, doc, cur, NULL);
|
htmlNodeDumpOutput(outbuf, doc, cur, NULL);
|
||||||
#else
|
#else
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlSaveErr(XML_ERR_INTERNAL_ERROR, "HTML support not compiled in\n");
|
||||||
"HTML support not compiled in\n");
|
|
||||||
#endif /* LIBXML_HTML_ENABLED */
|
#endif /* LIBXML_HTML_ENABLED */
|
||||||
} else
|
} else
|
||||||
xmlNodeDumpOutput(outbuf, doc, cur, 0, 1, NULL);
|
xmlNodeDumpOutput(outbuf, doc, cur, 0, 1, NULL);
|
||||||
@ -8139,8 +8190,6 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
|
|||||||
|
|
||||||
if (doc_txt_ptr == NULL) {
|
if (doc_txt_ptr == NULL) {
|
||||||
*doc_txt_len = 0;
|
*doc_txt_len = 0;
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlDocDumpFormatMemoryEnc: Null return buffer pointer.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8149,8 +8198,6 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
|
|||||||
|
|
||||||
if (out_doc == NULL) {
|
if (out_doc == NULL) {
|
||||||
/* No document, no output */
|
/* No document, no output */
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
|
||||||
"xmlDocDumpFormatMemoryEnc: Null DOM tree document pointer.\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8164,19 +8211,14 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
|
|||||||
if (txt_encoding != NULL) {
|
if (txt_encoding != NULL) {
|
||||||
conv_hdlr = xmlFindCharEncodingHandler(txt_encoding);
|
conv_hdlr = xmlFindCharEncodingHandler(txt_encoding);
|
||||||
if ( conv_hdlr == NULL ) {
|
if ( conv_hdlr == NULL ) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, (xmlNodePtr) out_doc,
|
||||||
"%s: %s %s '%s'\n",
|
txt_encoding);
|
||||||
"xmlDocDumpFormatMemoryEnc",
|
|
||||||
"Failed to identify encoding handler for",
|
|
||||||
"character set",
|
|
||||||
txt_encoding);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((out_buff = xmlAllocOutputBuffer(conv_hdlr)) == NULL ) {
|
if ((out_buff = xmlAllocOutputBuffer(conv_hdlr)) == NULL ) {
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlSaveErrMemory("creating buffer");
|
||||||
"xmlDocDumpFormatMemoryEnc: Failed to allocate output buffer.\n");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8193,9 +8235,7 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
|
|||||||
|
|
||||||
if ((*doc_txt_ptr == NULL) && (*doc_txt_len > 0)) {
|
if ((*doc_txt_ptr == NULL) && (*doc_txt_len > 0)) {
|
||||||
*doc_txt_len = 0;
|
*doc_txt_len = 0;
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
xmlSaveErrMemory("creating output");
|
||||||
"xmlDocDumpFormatMemoryEnc: %s\n",
|
|
||||||
"Failed to allocate memory for document text representation.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
Reference in New Issue
Block a user