Commit 3dbfa99f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Return XML attribute as const from NextAttr

The attribute name is valid until the next attribute or next node.
This simplifies the code a bit: fewer error paths, and free() calls.

A few potential memory leaks were fixed too.
parent 4bea014b
......@@ -73,7 +73,7 @@ struct xml_reader_t
int (*pf_next_node) ( xml_reader_t * );
char * (*pf_name) ( xml_reader_t * );
char * (*pf_value) ( xml_reader_t * );
int (*pf_next_attr) ( xml_reader_t * );
const char *(*pf_next_attr) ( xml_reader_t * );
int (*pf_use_dtd) ( xml_reader_t * );
};
......@@ -98,7 +98,7 @@ static inline char *xml_ReaderValue( xml_reader_t *reader )
return reader->pf_value( reader );
}
static inline int xml_ReaderNextAttr( xml_reader_t *reader )
static inline const char *xml_ReaderNextAttr( xml_reader_t *reader )
{
return reader->pf_next_attr( reader );
}
......
......@@ -583,19 +583,17 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
else if( !strcasecmp( "resolution", psz_node ) &&
( i_metadata_level == 1) )
{
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{
char *psz_name = xml_ReaderName ( p_xml_reader );
char *psz_value = xml_ReaderValue ( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value )
{
if( !strcasecmp( "x", psz_name ) )
p_sys->i_original_width = atoi( psz_value );
else if( !strcasecmp( "y", psz_name ) )
p_sys->i_original_height = atoi( psz_value );
}
free( psz_name );
if( !strcasecmp( "x", attr ) )
p_sys->i_original_width = atoi( psz_value );
else if( !strcasecmp( "y", attr ) )
p_sys->i_original_height = atoi( psz_value );
free( psz_value );
}
}
......@@ -633,183 +631,180 @@ static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader )
}
}
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{
char *psz_name = xml_ReaderName ( p_xml_reader );
char *psz_value = xml_ReaderValue ( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value )
if( !strcasecmp( "name", attr ) )
{
if( !strcasecmp( "name", psz_name ) )
p_ssa_style->psz_stylename = strdup( psz_value );
free( p_ssa_style->psz_stylename );
p_ssa_style->psz_stylename = strdup( psz_value );
}
free( psz_name );
free( psz_value );
}
}
else if( !strcasecmp( "fontstyle", psz_node ) && (i_style_level == 2) )
{
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{
char *psz_name = xml_ReaderName ( p_xml_reader );
char *psz_value = xml_ReaderValue ( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value )
if( !strcasecmp( "face", attr ) )
{
if( !strcasecmp( "face", psz_name ) )
{
free( p_ssa_style->font_style.psz_fontname );
p_ssa_style->font_style.psz_fontname = strdup( psz_value );
}
else if( !strcasecmp( "size", psz_name ) )
{
if( ( *psz_value == '+' ) || ( *psz_value == '-' ) )
{
int i_value = atoi( psz_value );
if( ( i_value >= -5 ) && ( i_value <= 5 ) )
p_ssa_style->font_style.i_font_size +=
( i_value * p_ssa_style->font_style.i_font_size ) / 10;
else if( i_value < -5 )
p_ssa_style->font_style.i_font_size = - i_value;
else if( i_value > 5 )
p_ssa_style->font_style.i_font_size = i_value;
}
else
p_ssa_style->font_style.i_font_size = atoi( psz_value );
}
else if( !strcasecmp( "italic", psz_name ) )
{
if( !strcasecmp( "yes", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_ITALIC;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_ITALIC;
}
else if( !strcasecmp( "weight", psz_name ) )
{
if( !strcasecmp( "bold", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_BOLD;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_BOLD;
}
else if( !strcasecmp( "underline", psz_name ) )
{
if( !strcasecmp( "yes", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_UNDERLINE;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_UNDERLINE;
}
else if( !strcasecmp( "color", psz_name ) )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_font_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_font_alpha = (col >> 24) & 0xff;
}
}
else if( !strcasecmp( "outline-color", psz_name ) )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_outline_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_outline_alpha = (col >> 24) & 0xff;
}
}
else if( !strcasecmp( "outline-level", psz_name ) )
free( p_ssa_style->font_style.psz_fontname );
p_ssa_style->font_style.psz_fontname = strdup( psz_value );
}
else if( !strcasecmp( "size", attr ) )
{
if( ( *psz_value == '+' ) || ( *psz_value == '-' ) )
{
p_ssa_style->font_style.i_outline_width = atoi( psz_value );
int i_value = atoi( psz_value );
if( ( i_value >= -5 ) && ( i_value <= 5 ) )
p_ssa_style->font_style.i_font_size +=
( i_value * p_ssa_style->font_style.i_font_size ) / 10;
else if( i_value < -5 )
p_ssa_style->font_style.i_font_size = - i_value;
else if( i_value > 5 )
p_ssa_style->font_style.i_font_size = i_value;
}
else if( !strcasecmp( "shadow-color", psz_name ) )
else
p_ssa_style->font_style.i_font_size = atoi( psz_value );
}
else if( !strcasecmp( "italic", attr ) )
{
if( !strcasecmp( "yes", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_ITALIC;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_ITALIC;
}
else if( !strcasecmp( "weight", attr ) )
{
if( !strcasecmp( "bold", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_BOLD;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_BOLD;
}
else if( !strcasecmp( "underline", attr ) )
{
if( !strcasecmp( "yes", psz_value ))
p_ssa_style->font_style.i_style_flags |= STYLE_UNDERLINE;
else
p_ssa_style->font_style.i_style_flags &= ~STYLE_UNDERLINE;
}
else if( !strcasecmp( "color", attr ) )
{
if( *psz_value == '#' )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_shadow_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_shadow_alpha = (col >> 24) & 0xff;
}
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_font_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_font_alpha = (col >> 24) & 0xff;
}
else if( !strcasecmp( "shadow-level", psz_name ) )
}
else if( !strcasecmp( "outline-color", attr ) )
{
if( *psz_value == '#' )
{
p_ssa_style->font_style.i_shadow_width = atoi( psz_value );
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_outline_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_outline_alpha = (col >> 24) & 0xff;
}
else if( !strcasecmp( "back-color", psz_name ) )
}
else if( !strcasecmp( "outline-level", attr ) )
{
p_ssa_style->font_style.i_outline_width = atoi( psz_value );
}
else if( !strcasecmp( "shadow-color", attr ) )
{
if( *psz_value == '#' )
{
if( *psz_value == '#' )
{
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_karaoke_background_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff;
}
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_shadow_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_shadow_alpha = (col >> 24) & 0xff;
}
else if( !strcasecmp( "spacing", psz_name ) )
}
else if( !strcasecmp( "shadow-level", attr ) )
{
p_ssa_style->font_style.i_shadow_width = atoi( psz_value );
}
else if( !strcasecmp( "back-color", attr ) )
{
if( *psz_value == '#' )
{
p_ssa_style->font_style.i_spacing = atoi( psz_value );
unsigned long col = strtol(psz_value+1, NULL, 16);
p_ssa_style->font_style.i_karaoke_background_color = (col & 0x00ffffff);
p_ssa_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff;
}
}
free( psz_name );
else if( !strcasecmp( "spacing", attr ) )
{
p_ssa_style->font_style.i_spacing = atoi( psz_value );
}
free( psz_value );
}
}
else if( !strcasecmp( "position", psz_node ) && (i_style_level == 2) )
{
while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{
char *psz_name = xml_ReaderName ( p_xml_reader );
char *psz_value = xml_ReaderValue ( p_xml_reader );
if( !psz_value )
continue;
if( psz_name && psz_value )
if( !strcasecmp( "alignment", attr ) )
{
if( !strcasecmp( "alignment", psz_name ) )
if( !strcasecmp( "TopLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "TopCenter", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP;
else if( !strcasecmp( "TopRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "MiddleLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "MiddleCenter", psz_value ) )
p_ssa_style->i_align = 0;
else if( !strcasecmp( "MiddleRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "BottomLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "BottomCenter", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM;
else if( !strcasecmp( "BottomRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;
}
else if( !strcasecmp( "horizontal-margin", attr ) )
{
if( strchr( psz_value, '%' ) )
{
p_ssa_style->i_margin_h = 0;
p_ssa_style->i_margin_percent_h = atoi( psz_value );
}
else
{
if( !strcasecmp( "TopLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "TopCenter", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP;
else if( !strcasecmp( "TopRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "MiddleLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "MiddleCenter", psz_value ) )
p_ssa_style->i_align = 0;
else if( !strcasecmp( "MiddleRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_RIGHT;
else if( !strcasecmp( "BottomLeft", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;
else if( !strcasecmp( "BottomCenter", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM;
else if( !strcasecmp( "BottomRight", psz_value ) )
p_ssa_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;
p_ssa_style->i_margin_h = atoi( psz_value );
p_ssa_style->i_margin_percent_h = 0;
}
else if( !strcasecmp( "horizontal-margin", psz_name ) )
}
else if( !strcasecmp( "vertical-margin", attr ) )
{
if( strchr( psz_value, '%' ) )
{
if( strchr( psz_value, '%' ) )
{
p_ssa_style->i_margin_h = 0;
p_ssa_style->i_margin_percent_h = atoi( psz_value );
}
else
{
p_ssa_style->i_margin_h = atoi( psz_value );
p_ssa_style->i_margin_percent_h = 0;
}
p_ssa_style->i_margin_v = 0;
p_ssa_style->i_margin_percent_v = atoi( psz_value );
}
else if( !strcasecmp( "vertical-margin", psz_name ) )
else
{
if( strchr( psz_value, '%' ) )
{
p_ssa_style->i_margin_v = 0;
p_ssa_style->i_margin_percent_v = atoi( psz_value );
}
else
{
p_ssa_style->i_margin_v = atoi( psz_value );
p_ssa_style->i_margin_percent_v = 0;
}
p_ssa_style->i_margin_v = atoi( psz_value );
p_ssa_style->i_margin_percent_v = 0;
}
}
free( psz_name );
free( psz_value );
}
}
......
......@@ -122,30 +122,23 @@ static int Demux( demux_t *p_demux )
FREENULL( psz_elname );
// Read the attributes
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value )
if( !psz_value )
{
free( psz_name );
free( psz_value );
goto end;
}
if( !strcmp( psz_name, "num_entries" ) )
{
if( !strcmp( attr, "num_entries" ) )
msg_Dbg( p_demux, "playlist has %d entries", atoi(psz_value) );
}
else if( !strcmp( psz_name, "label" ) )
{
else if( !strcmp( attr, "label" ) )
input_item_SetName( p_current_input, psz_value );
}
else
{
msg_Warn( p_demux, "stray attribute %s with value %s in element"
" 'playlist'", psz_name, psz_value );
}
free( psz_name );
" 'playlist'", attr, psz_value );
free( psz_value );
}
......@@ -165,28 +158,25 @@ static int Demux( demux_t *p_demux )
goto end;
// Read the attributes
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value )
if( !psz_value )
{
free( psz_name );
free( psz_value );
goto end;
}
if( !strcmp( psz_elname, "entry" ) &&
!strcmp( psz_name, "Playstring" ) )
!strcmp( attr, "Playstring" ) )
{
psz_mrl = psz_value;
}
else
{
msg_Warn( p_demux, "unexpected attribute %s in element %s",
psz_name, psz_elname );
attr, psz_elname );
free( psz_value );
}
free( psz_name );
}
break;
}
......
......@@ -132,24 +132,22 @@ static bool parse_plist_node( demux_t *p_demux, input_item_node_t *p_input_node,
xml_elem_hnd_t *p_handlers )
{
VLC_UNUSED(p_track); VLC_UNUSED(psz_element);
char *psz_name;
const char *attr;
char *psz_value;
bool b_version_found = false;
/* read all playlist attributes */
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{
psz_name = xml_ReaderName( p_xml_reader );
psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value )
if( !psz_value )
{
msg_Err( p_demux, "invalid xml stream @ <plist>" );
free( psz_name );
free( psz_value );
return false;
}
/* attribute: version */
if( !strcmp( psz_name, "version" ) )
if( !strcmp( attr, "version" ) )
{
b_version_found = true;
if( strcmp( psz_value, "1.0" ) )
......@@ -157,9 +155,8 @@ static bool parse_plist_node( demux_t *p_demux, input_item_node_t *p_input_node,
}
/* unknown attribute */
else
msg_Warn( p_demux, "invalid <plist> attribute:\"%s\"", psz_name);
msg_Warn( p_demux, "invalid <plist> attribute:\"%s\"", attr );
free( psz_name );
free( psz_value );
}
......
......@@ -136,30 +136,29 @@ static int Demux( demux_t *p_demux )
}
// Read the attributes
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
const char *attr;
while( (attr = xml_ReaderNextAttr( p_xml_reader )) )
{
char *psz_name = xml_ReaderName( p_xml_reader );
char *psz_value = xml_ReaderValue( p_xml_reader );
if( !psz_name || !psz_value )
if( !psz_value )
{
free( psz_name );
free( psz_value );
goto error;
}
if( !strcmp( psz_elname, "enclosure" ) )
{
if( !strcmp( psz_name, "url" ) )
if( !strcmp( attr, "url" ) )
{
free( psz_item_mrl );
psz_item_mrl = psz_value;
}
else if( !strcmp( psz_name, "length" ) )
else if( !strcmp( attr, "length" ) )
{
free( psz_item_size );
psz_item_size = psz_value;
}
else if( !strcmp( psz_name, "type" ) )
else if( !strcmp( attr, "type" ) )
{
free( psz_item_type );
psz_item_type = psz_value;
......@@ -167,17 +166,16 @@ static int Demux( demux_t *p_demux )
else
{
msg_Dbg( p_demux,"unhandled attribute %s in element %s",
psz_name, psz_elname );
attr, psz_elname );
free( psz_value );
}
}
else
{
msg_Dbg( p_demux,"unhandled attribute %s in element %s",
psz_name, psz_elname );
attr, psz_elname );
free( psz_value );
}
free( psz_name );
}
break;
}
......
......@@ -151,115 +151,81 @@ static int Demux( demux_t *p_demux )
}
free( psz_eltname );
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
const char *attrname;
while( (attrname = xml_ReaderNextAttr( p_xml_reader )) != NULL )
{
char *psz_attrname = xml_ReaderName( p_xml_reader );
char *psz_attrvalue = xml_ReaderValue( p_xml_reader );
if( !psz_attrname || !psz_attrvalue )
if( !psz_attrvalue )
{
free( psz_attrname );
free( psz_attrvalue );
goto error;
}
if( !strcmp( psz_attrname, "autoplay" ) )
{
if( !strcmp( attrname, "autoplay" ) )
b_autoplay = !strcmp( psz_attrvalue, "true" );
}
else if( !strcmp( psz_attrname, "controler" ) )
{
else if( !strcmp( attrname, "controler" ) )
b_controler = !strcmp( psz_attrvalue, "false" );
}
else if( !strcmp( psz_attrname, "fullscreen" ) )
else if( !strcmp( attrname, "fullscreen" ) )
{
if( !strcmp( psz_attrvalue, "double" ) )
{
fullscreen = FULLSCREEN_DOUBLE;
}
else if( !strcmp( psz_attrvalue, "half" ) )
{
fullscreen = FULLSCREEN_HALF;
}
else if( !strcmp( psz_attrvalue, "current" ) )
{
fullscreen = FULLSCREEN_CURRENT;
}
else if( !strcmp( psz_attrvalue, "full" ) )
{
fullscreen = FULLSCREEN_FULL;
}
else
{
fullscreen = FULLSCREEN_NORMAL;
}
}
else if( !strcmp( psz_attrname, "href" ) )
else if( !strcmp( attrname, "href" ) )
{
psz_href = psz_attrvalue;
psz_attrvalue = NULL;
}
else if( !strcmp( psz_attrname, "kioskmode" ) )
{
else if( !strcmp( attrname, "kioskmode" ) )
b_kioskmode = !strcmp( psz_attrvalue, "true" );
}
else if( !strcmp( psz_attrname, "loop" ) )
else if( !strcmp( attrname, "loop" ) )
{
if( !strcmp( psz_attrvalue, "true" ) )
{
loop = LOOP_TRUE;
}
else if( !strcmp( psz_attrvalue, "palindrome" ) )
{
loop = LOOP_PALINDROME;
}
else
{
loop = LOOP_FALSE;
}
}
else if( !strcmp( psz_attrname, "movieid" ) )
{
else if( !strcmp( attrname, "movieid" ) )
i_movieid = atoi( psz_attrvalue );
}
else if( !strcmp( psz_attrname, "moviename" ) )
else if( !strcmp( attrname, "moviename" ) )
{
psz_moviename = psz_attrvalue;
psz_attrvalue = NULL;
}
else if( !strcmp( psz_attrname, "playeveryframe" ) )
{
else if( !strcmp( attrname, "playeveryframe" ) )
b_playeveryframe = !strcmp( psz_attrvalue, "true" );
}
else if( !strcmp( psz_attrname, "qtnext" ) )
else if( !strcmp( attrname, "qtnext" ) )
{
psz_qtnext = psz_attrvalue;
psz_attrvalue = NULL;
}
else if( !strcmp( psz_attrname, "quitwhendone" ) )
{
else if( !strcmp( attrname, "quitwhendone" ) )
b_quitwhendone = !strcmp( psz_attrvalue, "true" );
}
else if( !strcmp( psz_attrname, "src" ) )
else if( !strcmp( attrname, "src" ) )
{
psz_src = psz_attrvalue;
psz_attrvalue = NULL;
}
else if( !strcmp( psz_attrname, "mimetype" ) )
else if( !strcmp( attrname, "mimetype" ) )
{
psz_mimetype = psz_attrvalue;
psz_attrvalue = NULL;
}
else if( !strcmp( psz_attrname, "volume" ) )
{
else if( !strcmp( attrname, "volume" ) )
i_volume = atoi( psz_attrvalue );
}
else
{
msg_Dbg( p_demux, "Attribute %s with value %s isn't valid",
psz_attrname, psz_attrvalue );
}
free( psz_attrname );
attrname, psz_attrvalue );
free( psz_attrvalue );
}
......
......@@ -135,7 +135,7 @@ error:
}
#define GET_VALUE( a ) \
if( !strcmp( psz_attrname, #a ) ) \
if( !strcmp( attrname, #a ) ) \
{ \
free(psz_ ## a); \
psz_ ## a = psz_attrvalue; \
......@@ -165,14 +165,12 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
if( !strcmp( psz_eltname, "genre" ) )
{
// Read the attributes
while( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )
const char *attrname;
while( (attrname = xml_ReaderNextAttr( p_xml_reader )) )
{
char *psz_attrname = xml_ReaderName( p_xml_reader );
char *psz_attrvalue =
xml_ReaderValue( p_xml_reader );
if( !psz_attrname || !psz_attrvalue )
char *psz_attrvalue = xml_ReaderValue( p_xml_reader );
if( !psz_attrvalue )
{
free( psz_attrname );
free( psz_attrvalue );
break;
}
......@@ -182,10 +180,9 @@ static int DemuxGenre( demux_t *p_demux, xml_reader_t *p_xml_reader,
{
msg_Warn( p_demux,
"unexpected attribute %s in element %s",
psz_attrname, psz_eltname );
attrname, psz_eltname );
free( psz_attrvalue );
}
free( psz_attrname );
}
}
free( psz_eltname );
......@@ -286,15 +283,13 @@ static int DemuxStation( demux_t *p_demux, xml_reader_t *p_xml_reader,
// Read the attributes
if( !strcmp( psz_eltname, "tunein" ) )
{