]> git.sesse.net Git - vlc/blobdiff - modules/misc/xml/xtag.c
Do not assert memory allocations
[vlc] / modules / misc / xml / xtag.c
index de4b6ea82fe7dd1dab56cdf7623461f4c9310a00..779fd40ae7da2efa47af60ccc74c36c084d87126 100644 (file)
@@ -41,8 +41,6 @@
 #include <ctype.h>
 #include <stdarg.h>
 
-#include <assert.h>
-
 #undef XTAG_DEBUG
 
 typedef struct _XList
@@ -351,8 +349,7 @@ static XList *xlist_append( XList *list, void *data )
 {
     XList *l, *last;
 
-    l = (XList *)malloc( sizeof(XList) );
-    assert( l );
+    l = (XList *)xmalloc( sizeof(XList) );
     l->prev = l->next = NULL;
     l->data = data;
 
@@ -457,8 +454,7 @@ static char *xtag_slurp_to( XTagParser *parser, int good_end, int bad_end )
 
     if( xi > 0 && xtag_cin (s[xi], good_end) )
     {
-        ret = malloc( xi+1 );
-        assert( ret );
+        ret = xmalloc( xi+1 );
         strncpy( ret, s, xi );
         ret[xi] = '\0';
         parser->start = &s[xi];
@@ -511,8 +507,7 @@ static char *xtag_slurp_quoted( XTagParser *parser )
         }
     }
 
-    ret = malloc( xi+1 );
-    assert( ret );
+    ret = xmalloc( xi+1 );
     strncpy( ret, s, xi );
     ret[xi] = '\0';
     parser->start = &s[xi];
@@ -564,8 +559,7 @@ static XAttribute *xtag_parse_attribute( XTagParser *parser )
         goto err_free_name;
     }
 
-    attr = malloc( sizeof (*attr) );
-    assert( attr );
+    attr = xmalloc( sizeof (*attr) );
     attr->name = name;
     attr->value = value;
     return attr;
@@ -639,8 +633,7 @@ static XTag *xtag_parse_tag( XTagParser *parser )
 
     if( (pcdata = xtag_slurp_to( parser, X_OPENTAG, X_NONE )) != NULL )
     {
-        tag = malloc( sizeof(*tag) );
-        assert( tag );
+        tag = xmalloc( sizeof(*tag) );
         tag->name = NULL;
         tag->pcdata = pcdata;
         tag->parent = parser->current_tag;
@@ -694,8 +687,7 @@ static XTag *xtag_parse_tag( XTagParser *parser )
     fprintf (stderr, "<%s ...\n", name);
 #endif
 
-    tag = malloc( sizeof(*tag) );
-    assert( tag );
+    tag = xmalloc( sizeof(*tag) );
     tag->name = name;
     tag->pcdata = NULL;
     tag->parent = parser->current_tag;
@@ -834,8 +826,7 @@ static XTag *xtag_new_parse( const char *s, int n )
             return tag;
         }
 
-        wrapper = malloc( sizeof(XTag) );
-        assert( wrapper );
+        wrapper = xmalloc( sizeof(XTag) );
         wrapper->name = NULL;
         wrapper->pcdata = NULL;
         wrapper->parent = NULL;