Commit d005b9e8 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

more fixes and extending the tests coverage more fixes and hardening

* gentest.py testapi.c: more fixes and extending the tests coverage
* list.c tree.c: more fixes and hardening
Daniel
parent dd6d3008
Wed Nov 3 18:06:44 CET 2004 Daniel Veillard <daniel@veillard.com>
* gentest.py testapi.c: more fixes and extending the tests coverage
* list.c tree.c: more fixes and hardening
Wed Nov 3 15:19:22 CET 2004 Daniel Veillard <daniel@veillard.com> Wed Nov 3 15:19:22 CET 2004 Daniel Veillard <daniel@veillard.com>
* gentest.py testapi.c: more fixes and extending the tests coverage * gentest.py testapi.c: more fixes and extending the tests coverage
......
...@@ -15,7 +15,12 @@ except: ...@@ -15,7 +15,12 @@ except:
# #
skipped_modules = [ "SAX", "SAX2", "xlink", "threads", "globals", skipped_modules = [ "SAX", "SAX2", "xlink", "threads", "globals",
"xpathInternals", "xmlunicode", "parserInternals", "xmlmemory", "xpathInternals", "xmlunicode", "parserInternals", "xmlmemory",
"xmlversion", "debugXML", "xmlexports" ] "xmlversion", "debugXML", "xmlexports",
# temporary
"xmlautomata", "xmlregexp",
]
# #
# Some function really need to be skipped for the tests. # Some function really need to be skipped for the tests.
...@@ -32,7 +37,11 @@ skipped_functions = [ ...@@ -32,7 +37,11 @@ skipped_functions = [
"xmlStrcat", "xmlStrncat", "xmlStrcat", "xmlStrncat",
# unimplemented # unimplemented
"xmlTextReaderReadInnerXml", "xmlTextReaderReadOuterXml", "xmlTextReaderReadInnerXml", "xmlTextReaderReadOuterXml",
"xmlTextReaderReadString" "xmlTextReaderReadString",
# destructor
"xmlListDelete",
# deprecated
"xmlCatalogGetPublic", "xmlCatalogGetSystem", "xmlEncodeEntities",
] ]
# #
...@@ -232,6 +241,8 @@ def type_convert(str, name, info, module, function, pos): ...@@ -232,6 +241,8 @@ def type_convert(str, name, info, module, function, pos):
return('xmlNanoHTTPCtxtPtr') return('xmlNanoHTTPCtxtPtr')
if string.find(name, "data") != -1: if string.find(name, "data") != -1:
return('userdata'); return('userdata');
if string.find(name, "user") != -1:
return('userdata');
if res == 'xmlNodePtr' and pos != 0: if res == 'xmlNodePtr' and pos != 0:
if (function == 'xmlAddChild' and pos == 2) or \ if (function == 'xmlAddChild' and pos == 2) or \
(function == 'xmlAddChildList' and pos == 2) or \ (function == 'xmlAddChildList' and pos == 2) or \
...@@ -248,7 +259,9 @@ def type_convert(str, name, info, module, function, pos): ...@@ -248,7 +259,9 @@ def type_convert(str, name, info, module, function, pos):
known_param_types = [ "int", "const_char_ptr", "const_xmlChar_ptr", known_param_types = [ "int", "const_char_ptr", "const_xmlChar_ptr",
"xmlParserCtxtPtr", "xmlDocPtr", "filepath", "fileoutput", "xmlParserCtxtPtr", "xmlDocPtr", "filepath", "fileoutput",
"xmlNodePtr", "xmlNodePtr_in", "userdata", "xmlChar_ptr", "xmlNodePtr", "xmlNodePtr_in", "userdata", "xmlChar_ptr",
"xmlTextWriterPtr", "xmlTextReaderPtr" ]; "xmlTextWriterPtr", "xmlTextReaderPtr", "xmlBufferPtr",
"xmlListPtr", "xmlXPathObjectPtr", "xmlHashTablePtr",
]
def is_known_param_type(name): def is_known_param_type(name):
for type in known_param_types: for type in known_param_types:
...@@ -294,7 +307,7 @@ static void des_const_char_ptr(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUT ...@@ -294,7 +307,7 @@ static void des_const_char_ptr(int no ATTRIBUTE_UNUSED, const char *val ATTRIBUT
#define gen_nb_xmlChar_ptr 2 #define gen_nb_xmlChar_ptr 2
static xmlChar *gen_xmlChar_ptr(int no) { static xmlChar *gen_xmlChar_ptr(int no) {
if (no == 0) return(&chartab); if (no == 0) return(&chartab[0]);
return(NULL); return(NULL);
} }
static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED) { static void des_xmlChar_ptr(int no ATTRIBUTE_UNUSED, xmlChar *val ATTRIBUTE_UNUSED) {
...@@ -402,6 +415,55 @@ static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val) ...@@ -402,6 +415,55 @@ static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val)
if (val != NULL) xmlFreeTextReader(val); if (val != NULL) xmlFreeTextReader(val);
} }
#define gen_nb_xmlBufferPtr 2
static xmlBufferPtr gen_xmlBufferPtr(int no) {
if (no == 0) return(xmlBufferCreate());
return(NULL);
}
static void des_xmlBufferPtr(int no ATTRIBUTE_UNUSED, xmlBufferPtr val) {
if (val != NULL) {
xmlBufferFree(val);
}
}
#define gen_nb_xmlListPtr 2
static xmlListPtr gen_xmlListPtr(int no) {
if (no == 0) return(xmlListCreate(NULL, NULL));
return(NULL);
}
static void des_xmlListPtr(int no ATTRIBUTE_UNUSED, xmlListPtr val) {
if (val != NULL) {
xmlListDelete(val);
}
}
#define gen_nb_xmlHashTablePtr 2
static xmlHashTablePtr gen_xmlHashTablePtr(int no) {
if (no == 0) return(xmlHashCreate(10));
return(NULL);
}
static void des_xmlHashTablePtr(int no ATTRIBUTE_UNUSED, xmlHashTablePtr val) {
if (val != NULL) {
xmlHashFree(val, NULL);
}
}
#include <libxml/xpathInternals.h>
#define gen_nb_xmlXPathObjectPtr 5
static xmlXPathObjectPtr gen_xmlXPathObjectPtr(int no) {
if (no == 0) return(xmlXPathNewString(BAD_CAST "string object"));
if (no == 1) return(xmlXPathNewFloat(1.1));
if (no == 2) return(xmlXPathNewBoolean(1));
if (no == 3) return(xmlXPathNewNodeSet(NULL));
return(NULL);
}
static void des_xmlXPathObjectPtr(int no ATTRIBUTE_UNUSED, xmlXPathObjectPtr val) {
if (val != NULL) {
xmlXPathFreeObject(val);
}
}
"""); """);
# #
...@@ -409,7 +471,7 @@ static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val) ...@@ -409,7 +471,7 @@ static void des_xmlTextReaderPtr(int no ATTRIBUTE_UNUSED, xmlTextReaderPtr val)
# #
known_return_types = [ "int", "const_char_ptr", "xmlDocPtr", "xmlNodePtr", known_return_types = [ "int", "const_char_ptr", "xmlDocPtr", "xmlNodePtr",
"xmlChar_ptr" ]; "xmlChar_ptr", "const_xmlChar_ptr" ];
def is_known_return_type(name): def is_known_return_type(name):
for type in known_return_types: for type in known_return_types:
...@@ -422,6 +484,8 @@ static void desret_int(int val ATTRIBUTE_UNUSED) { ...@@ -422,6 +484,8 @@ static void desret_int(int val ATTRIBUTE_UNUSED) {
} }
static void desret_const_char_ptr(const char *val ATTRIBUTE_UNUSED) { static void desret_const_char_ptr(const char *val ATTRIBUTE_UNUSED) {
} }
static void desret_const_xmlChar_ptr(const xmlChar *val ATTRIBUTE_UNUSED) {
}
static void desret_xmlChar_ptr(xmlChar *val) { static void desret_xmlChar_ptr(xmlChar *val) {
if (val != NULL) if (val != NULL)
xmlFree(val); xmlFree(val);
...@@ -686,15 +750,32 @@ test_%s(void) { ...@@ -686,15 +750,32 @@ test_%s(void) {
""" % (module)) """ % (module))
print "Generated test for %d modules and %d functions" %(len(modules), nb_tests) print "Generated test for %d modules and %d functions" %(len(modules), nb_tests)
nr = 0 nr1 = 0
miss = 'none' miss1 = 'none'
nr2 = 0
miss2 = 'none'
nr3 = 0
miss3 = 'none'
for missing in missing_types.keys(): for missing in missing_types.keys():
n = len(missing_types[missing]) n = len(missing_types[missing])
if n > nr: if n > nr1:
miss = missing miss3 = miss2
nr = n nr3 = nr2
miss2 = miss1
if nr > 0: nr2 = nr1
print "most needed type support: %s %d times" % (miss, nr) miss1 = missing
nr1 = n
elif n > nr2:
miss3 = miss2
nr3 = nr2
miss2 = missing
nr2 = n
elif n > nr3:
miss3 = missing
nr3 = n
if nr1 > 0:
print "most needed type support: %s %d times, %s %d and %s %d" % (
miss1, nr1, miss2, nr2, miss3, nr3)
...@@ -99,6 +99,8 @@ xmlListLowerSearch(xmlListPtr l, void *data) ...@@ -99,6 +99,8 @@ xmlListLowerSearch(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;
if (l == NULL)
return(NULL);
for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next); for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next);
return lk; return lk;
} }
...@@ -117,6 +119,8 @@ xmlListHigherSearch(xmlListPtr l, void *data) ...@@ -117,6 +119,8 @@ xmlListHigherSearch(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;
if (l == NULL)
return(NULL);
for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev); for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev);
return lk; return lk;
} }
...@@ -134,6 +138,8 @@ static xmlLinkPtr ...@@ -134,6 +138,8 @@ static xmlLinkPtr
xmlListLinkSearch(xmlListPtr l, void *data) xmlListLinkSearch(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;
if (l == NULL)
return(NULL);
lk = xmlListLowerSearch(l, data); lk = xmlListLowerSearch(l, data);
if (lk == l->sentinel) if (lk == l->sentinel)
return NULL; return NULL;
...@@ -157,6 +163,8 @@ static xmlLinkPtr ...@@ -157,6 +163,8 @@ static xmlLinkPtr
xmlListLinkReverseSearch(xmlListPtr l, void *data) xmlListLinkReverseSearch(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;
if (l == NULL)
return(NULL);
lk = xmlListHigherSearch(l, data); lk = xmlListHigherSearch(l, data);
if (lk == l->sentinel) if (lk == l->sentinel)
return NULL; return NULL;
...@@ -223,6 +231,8 @@ void * ...@@ -223,6 +231,8 @@ void *
xmlListSearch(xmlListPtr l, void *data) xmlListSearch(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;
if (l == NULL)
return(NULL);
lk = xmlListLinkSearch(l, data); lk = xmlListLinkSearch(l, data);
if (lk) if (lk)
return (lk->data); return (lk->data);
...@@ -242,6 +252,8 @@ void * ...@@ -242,6 +252,8 @@ void *
xmlListReverseSearch(xmlListPtr l, void *data) xmlListReverseSearch(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;
if (l == NULL)
return(NULL);
lk = xmlListLinkReverseSearch(l, data); lk = xmlListLinkReverseSearch(l, data);
if (lk) if (lk)
return (lk->data); return (lk->data);
...@@ -262,6 +274,8 @@ xmlListInsert(xmlListPtr l, void *data) ...@@ -262,6 +274,8 @@ xmlListInsert(xmlListPtr l, void *data)
{ {
xmlLinkPtr lkPlace, lkNew; xmlLinkPtr lkPlace, lkNew;
if (l == NULL)
return(1);
lkPlace = xmlListLowerSearch(l, data); lkPlace = xmlListLowerSearch(l, data);
/* Add the new link */ /* Add the new link */
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
...@@ -292,6 +306,8 @@ int xmlListAppend(xmlListPtr l, void *data) ...@@ -292,6 +306,8 @@ int xmlListAppend(xmlListPtr l, void *data)
{ {
xmlLinkPtr lkPlace, lkNew; xmlLinkPtr lkPlace, lkNew;
if (l == NULL)
return(1);
lkPlace = xmlListHigherSearch(l, data); lkPlace = xmlListHigherSearch(l, data);
/* Add the new link */ /* Add the new link */
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
...@@ -338,6 +354,8 @@ xmlListRemoveFirst(xmlListPtr l, void *data) ...@@ -338,6 +354,8 @@ xmlListRemoveFirst(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;
if (l == NULL)
return(0);
/*Find the first instance of this data */ /*Find the first instance of this data */
lk = xmlListLinkSearch(l, data); lk = xmlListLinkSearch(l, data);
if (lk != NULL) { if (lk != NULL) {
...@@ -361,6 +379,8 @@ xmlListRemoveLast(xmlListPtr l, void *data) ...@@ -361,6 +379,8 @@ xmlListRemoveLast(xmlListPtr l, void *data)
{ {
xmlLinkPtr lk; xmlLinkPtr lk;
if (l == NULL)
return(0);
/*Find the last instance of this data */ /*Find the last instance of this data */
lk = xmlListLinkReverseSearch(l, data); lk = xmlListLinkReverseSearch(l, data);
if (lk != NULL) { if (lk != NULL) {
...@@ -384,6 +404,8 @@ xmlListRemoveAll(xmlListPtr l, void *data) ...@@ -384,6 +404,8 @@ xmlListRemoveAll(xmlListPtr l, void *data)
{ {
int count=0; int count=0;
if (l == NULL)
return(0);
while(xmlListRemoveFirst(l, data)) while(xmlListRemoveFirst(l, data))
count++; count++;
...@@ -399,8 +421,11 @@ xmlListRemoveAll(xmlListPtr l, void *data) ...@@ -399,8 +421,11 @@ xmlListRemoveAll(xmlListPtr l, void *data)
void void
xmlListClear(xmlListPtr l) xmlListClear(xmlListPtr l)
{ {
xmlLinkPtr lk = l->sentinel->next; xmlLinkPtr lk;
if (l == NULL)
return;
lk = l->sentinel->next;
while(lk != l->sentinel) { while(lk != l->sentinel) {
xmlLinkPtr next = lk->next; xmlLinkPtr next = lk->next;
...@@ -415,11 +440,13 @@ xmlListClear(xmlListPtr l) ...@@ -415,11 +440,13 @@ xmlListClear(xmlListPtr l)
* *
* Is the list empty ? * Is the list empty ?
* *
* Returns 1 if the list is empty, 0 otherwise * Returns 1 if the list is empty, 0 if not empty and -1 in case of error
*/ */
int int
xmlListEmpty(xmlListPtr l) xmlListEmpty(xmlListPtr l)
{ {
if (l == NULL)
return(-1);
return (l->sentinel->next == l->sentinel); return (l->sentinel->next == l->sentinel);
} }
...@@ -434,6 +461,8 @@ xmlListEmpty(xmlListPtr l) ...@@ -434,6 +461,8 @@ xmlListEmpty(xmlListPtr l)
xmlLinkPtr xmlLinkPtr
xmlListFront(xmlListPtr l) xmlListFront(xmlListPtr l)
{ {
if (l == NULL)
return(NULL);
return (l->sentinel->next); return (l->sentinel->next);
} }
...@@ -448,6 +477,8 @@ xmlListFront(xmlListPtr l) ...@@ -448,6 +477,8 @@ xmlListFront(xmlListPtr l)
xmlLinkPtr xmlLinkPtr
xmlListEnd(xmlListPtr l) xmlListEnd(xmlListPtr l)
{ {
if (l == NULL)
return(NULL);
return (l->sentinel->prev); return (l->sentinel->prev);
} }
...@@ -457,7 +488,7 @@ xmlListEnd(xmlListPtr l) ...@@ -457,7 +488,7 @@ xmlListEnd(xmlListPtr l)
* *
* Get the number of elements in the list * Get the number of elements in the list
* *
* Returns the number of elements in the list * Returns the number of elements in the list or -1 in case of error
*/ */
int int
xmlListSize(xmlListPtr l) xmlListSize(xmlListPtr l)
...@@ -465,6 +496,8 @@ xmlListSize(xmlListPtr l) ...@@ -465,6 +496,8 @@ xmlListSize(xmlListPtr l)
xmlLinkPtr lk; xmlLinkPtr lk;
int count=0; int count=0;
if (l == NULL)
return(-1);
/* TODO: keep a counter in xmlList instead */ /* TODO: keep a counter in xmlList instead */
for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next, count++); for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next, count++);
return count; return count;
...@@ -510,6 +543,8 @@ xmlListPushFront(xmlListPtr l, void *data) ...@@ -510,6 +543,8 @@ xmlListPushFront(xmlListPtr l, void *data)
{ {
xmlLinkPtr lkPlace, lkNew; xmlLinkPtr lkPlace, lkNew;
if (l == NULL)
return(0);
lkPlace = l->sentinel; lkPlace = l->sentinel;
/* Add the new link */ /* Add the new link */
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink)); lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
...@@ -540,6 +575,8 @@ xmlListPushBack(xmlListPtr l, void *data) ...@@ -540,6 +575,8 @@ xmlListPushBack(xmlListPtr l, void *data)
{ {
xmlLinkPtr lkPlace, lkNew; xmlLinkPtr lkPlace, lkNew;
if (l == NULL)
return(0);
lkPlace = l->sentinel->prev; lkPlace = l->sentinel->prev;
/* Add the new link */ /* Add the new link */
if (NULL ==(lkNew = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) { if (NULL ==(lkNew = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) {
...@@ -566,6 +603,8 @@ xmlListPushBack(xmlListPtr l, void *data) ...@@ -566,6 +603,8 @@ xmlListPushBack(xmlListPtr l, void *data)
void * void *
xmlLinkGetData(xmlLinkPtr lk) xmlLinkGetData(xmlLinkPtr lk)
{ {
if (lk == NULL)
return(NULL);
return lk->data; return lk->data;
} }
...@@ -576,18 +615,22 @@ xmlLinkGetData(xmlLinkPtr lk) ...@@ -576,18 +615,22 @@ xmlLinkGetData(xmlLinkPtr lk)
* Reverse the order of the elements in the list * Reverse the order of the elements in the list
*/ */
void void
xmlListReverse(xmlListPtr l) { xmlListReverse(xmlListPtr l)
xmlLinkPtr lk; {
xmlLinkPtr lkPrev = l->sentinel; xmlLinkPtr lk;
xmlLinkPtr lkPrev;
for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) {
if (l == NULL)
return;
lkPrev = l->sentinel;
for (lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) {
lkPrev->next = lkPrev->prev;
lkPrev->prev = lk;
lkPrev = lk;
}
/* Fix up the last node */
lkPrev->next = lkPrev->prev; lkPrev->next = lkPrev->prev;
lkPrev->prev = lk; lkPrev->prev = lk;
lkPrev = lk;
}
/* Fix up the last node */
lkPrev->next = lkPrev->prev;
lkPrev->prev = lk;
} }
/** /**
...@@ -601,6 +644,8 @@ xmlListSort(xmlListPtr l) ...@@ -601,6 +644,8 @@ xmlListSort(xmlListPtr l)
{ {
xmlListPtr lTemp; xmlListPtr lTemp;
if (l == NULL)
return;
if(xmlListEmpty(l)) if(xmlListEmpty(l))
return; return;
...@@ -631,6 +676,8 @@ void ...@@ -631,6 +676,8 @@ void
xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) { xmlListWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
xmlLinkPtr lk; xmlLinkPtr lk;
if ((l == NULL) || (walker == NULL))
return;
for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) { for(lk = l->sentinel->next; lk != l->sentinel; lk = lk->next) {
if((walker(lk->data, user)) == 0) if((walker(lk->data, user)) == 0)
break; break;
...@@ -650,6 +697,8 @@ void ...@@ -650,6 +697,8 @@ void
xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, const void *user) { xmlListReverseWalk(xmlListPtr l, xmlListWalker walker, const void *user) {
xmlLinkPtr lk; xmlLinkPtr lk;
if ((l == NULL) || (walker == NULL))
return;
for(lk = l->sentinel->prev; lk != l->sentinel; lk = lk->prev) { for(lk = l->sentinel->prev; lk != l->sentinel; lk = lk->prev) {
if((walker(lk->data, user)) == 0) if((walker(lk->data, user)) == 0)
break; break;
...@@ -683,6 +732,9 @@ xmlListPtr ...@@ -683,6 +732,9 @@ xmlListPtr
xmlListDup(const xmlListPtr old) xmlListDup(const xmlListPtr old)
{ {
xmlListPtr cur; xmlListPtr cur;
if (old == NULL)
return(NULL);
/* Hmmm, how to best deal with allocation issues when copying /* Hmmm, how to best deal with allocation issues when copying
* lists. If there is a de-allocator, should responsibility lie with * lists. If there is a de-allocator, should responsibility lie with
* the new list or the old list. Surely not both. I'll arbitrarily * the new list or the old list. Surely not both. I'll arbitrarily
...@@ -711,6 +763,8 @@ xmlListCopy(xmlListPtr cur, const xmlListPtr old) ...@@ -711,6 +763,8 @@ xmlListCopy(xmlListPtr cur, const xmlListPtr old)
/* Walk the old tree and insert the data into the new one */ /* Walk the old tree and insert the data into the new one */
xmlLinkPtr lk; xmlLinkPtr lk;
if ((old == NULL) || (cur == NULL))
return(1);
for(lk = old->sentinel->next; lk != old->sentinel; lk = lk->next) { for(lk = old->sentinel->next; lk != old->sentinel; lk = lk->next) {
if (0 !=xmlListInsert(cur, lk->data)) { if (0 !=xmlListInsert(cur, lk->data)) {
xmlListDelete(cur); xmlListDelete(cur);
......
This diff is collapsed.
...@@ -6688,6 +6688,7 @@ xmlBufferFree(xmlBufferPtr buf) { ...@@ -6688,6 +6688,7 @@ xmlBufferFree(xmlBufferPtr buf) {
*/ */
void void
xmlBufferEmpty(xmlBufferPtr buf) { xmlBufferEmpty(xmlBufferPtr buf) {
if (buf == NULL) return;
if (buf->content == NULL) return; if (buf->content == NULL) return;
buf->use = 0; buf->use = 0;
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) { if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
...@@ -6844,6 +6845,9 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size) ...@@ -6844,6 +6845,9 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
unsigned int newSize; unsigned int newSize;
xmlChar* rebuf = NULL; xmlChar* rebuf = NULL;
if (buf == NULL)
return(0);
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0); if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
/* Don't resize if we don't have to */ /* Don't resize if we don't have to */
...@@ -6909,11 +6913,7 @@ int ...@@ -6909,11 +6913,7 @@ int
xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) { xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
unsigned int needSize; unsigned int needSize;
if (str == NULL) { if ((str == NULL) || (buf == NULL)) {
#ifdef DEBUG_BUFFER