1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-21 14:53:44 +03:00

more memory related code cleanups. Daniel

* HTMLparser.c parser.c relaxng.c xmlschemas.c: more memory related
  code cleanups.
Daniel
This commit is contained in:
Daniel Veillard
2004-09-23 13:15:03 +00:00
parent 2248ff178b
commit 079f6a7559
5 changed files with 32 additions and 13 deletions

View File

@@ -1703,12 +1703,15 @@ static const htmlEntityDesc html40EntitiesTable[] = {
* Macro used to grow the current buffer.
*/
#define growBuffer(buffer) { \
xmlChar *tmp; \
buffer##_size *= 2; \
buffer = (xmlChar *) xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \
if (buffer == NULL) { \
tmp = (xmlChar *) xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \
if (tmp == NULL) { \
htmlErrMemory(ctxt, "growing buffer\n"); \
xmlFree(buffer); \
return(NULL); \
} \
buffer = tmp; \
}
/**
@@ -2849,13 +2852,17 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
((cur != '>') ||
(r != '-') || (q != '-'))) {
if (len + 5 >= size) {
xmlChar *tmp;
size *= 2;
buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
if (buf == NULL) {
tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
if (tmp == NULL) {
xmlFree(buf);
htmlErrMemory(ctxt, "growing buffer failed\n");
ctxt->instate = state;
return;
}
buf = tmp;
}
COPY_BUF(ql,buf,len,q);
q = r;