]> git.sesse.net Git - vlc/blobdiff - modules/codec/cmml/xtag.c
cmml: less includes.
[vlc] / modules / codec / cmml / xtag.c
index 44fe169466b45d0bf1319557f1f4e79134a89b35..3a661b906297e040940adeb7b4b30095315d55ab 100644 (file)
@@ -79,12 +79,12 @@ struct _XTagParser {
   char * end;
 };
 
-XTag * xtag_free (XTag * xtag);
+void   xtag_free (XTag * xtag);
 XTag * xtag_new_parse (const char * s, int n);
 char * xtag_get_name (XTag * xtag);
 char * xtag_get_pcdata (XTag * xtag);
-char * xtag_get_attribute (XTag * xtag, char * attribute);
-XTag * xtag_first_child (XTag * xtag, char * name);
+char * xtag_get_attribute (XTag * xtag, const char* attribute);
+XTag * xtag_first_child (XTag * xtag, const char * name);
 XTag * xtag_next_child (XTag * xtag, char * name);
 int    xtag_snprint (char * buf, int n, XTag * xtag);
 
@@ -260,7 +260,11 @@ xtag_slurp_quoted (XTagParser * parser)
   ret[xi] = '\0';
   parser->start = &s[xi];
 
-  if (!xtag_assert_and_pass (parser, quote)) return NULL;
+  if (!xtag_assert_and_pass (parser, quote))
+  {
+     free( ret );
+     return NULL;
+  }
 
   return ret;
 }
@@ -410,20 +414,20 @@ xtag_parse_tag (XTagParser * parser)
   return tag;
 }
 
-XTag *
-xtag_free (XTag * xtag)
+void xtag_free (XTag * xtag)
 {
   XList * l;
   XAttribute * attr;
   XTag * child;
 
-  if (xtag == NULL) return NULL;
+  if( !xtag )
+    return;
 
   free( xtag->name );
   free( xtag->pcdata );
 
-  for (l = xtag->attributes; l; l = l->next) {
-    if ((attr = (XAttribute *)l->data) != NULL) {
+  forl = xtag->attributes; l; l = l->next) {
+    if((attr = (XAttribute *)l->data) != NULL) {
       free( attr->name );
       free( attr->value );
       free( attr );
@@ -433,13 +437,11 @@ xtag_free (XTag * xtag)
 
   for (l = xtag->children; l; l = l->next) {
     child = (XTag *)l->data;
-    xtag_free (child);
+    xtag_free( child );
   }
   xlist_free (xtag->children);
 
-  free (xtag);
-
-  return NULL;
+  free( xtag );
 }
 
 XTag *
@@ -523,51 +525,55 @@ xtag_get_pcdata (XTag * xtag)
   return NULL;
 }
 
-char *
-xtag_get_attribute (XTag * xtag, char * attribute)
+char* xtag_get_attribute (XTag * xtag, const char * attribute)
 {
-  XList * l;
-  XAttribute * attr;
-
-  if (xtag == NULL) return NULL;
-
-  for (l = xtag->attributes; l; l = l->next) {
-    if ((attr = (XAttribute *)l->data) != NULL) {
-      if (attr->name && attribute && !strcmp (attr->name, attribute))
-        return attr->value;
+    XList * l;
+    XAttribute * attr;
+
+    if( !xtag )
+        return NULL;
+
+    for( l = xtag->attributes; l; l = l->next )
+    {
+        if( ( attr = (XAttribute *)l->data ) != NULL )
+        {
+            if( attr->name && attribute && !strcmp( attr->name, attribute ) )
+                return attr->value;
+        }
     }
-  }
-
-  return NULL;
+    return NULL;
 }
 
-XTag *
-xtag_first_child (XTag * xtag, char * name)
+XTag* xtag_first_child (XTag * xtag, const char * name)
 {
-  XList * l;
-  XTag * child;
+    XList * l;
+    XTag * child;
 
-  if (xtag == NULL) return NULL;
+    if( !xtag )
+        return NULL;
 
-  if ((l = xtag->children) == NULL) return NULL;
+    if( ( l = xtag->children ) == NULL )
+        return NULL;
 
-  if (name == NULL) {
-    xtag->current_child = l;
-    return (XTag *)l->data;
-  }
+    if( !name )
+    {
+        xtag->current_child = l;
+        return (XTag *)l->data;
+    }
 
-  for (; l; l = l->next) {
-    child = (XTag *)l->data;
+    for( ; l; l = l->next )
+    {
+        child = (XTag *)l->data;
 
-    if (child->name && name && !strcmp(child->name, name)) {
-      xtag->current_child = l;
-      return child;
+        if( child->name && name && !strcmp( child->name, name ) )
+        {
+            xtag->current_child = l;
+            return child;
+        }
     }
-  }
 
-  xtag->current_child = NULL;
-
-  return NULL;
+    xtag->current_child = NULL;
+    return NULL;
 }
 
 XTag *