]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/rss.c
video_filter_rss: cosmetics.
[vlc] / modules / video_filter / rss.c
index f4d9e215890068e580ea31174e52576a2abe6ccd..9e7b1df65ca679bf8da20cc4f955ed6b31108547 100644 (file)
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
-#include <vlc_vout.h>
 
-#include "vlc_filter.h"
-#include "vlc_block.h"
-#include "vlc_osd.h"
+#include <vlc_filter.h>
+#include <vlc_block.h>
+#include <vlc_osd.h>
 
-#include "vlc_block.h"
-#include "vlc_stream.h"
-#include "vlc_xml.h"
+#include <vlc_block.h>
+#include <vlc_stream.h>
+#include <vlc_xml.h>
 #include <vlc_charset.h>
 
-#include "vlc_image.h"
+#include <vlc_image.h>
 
 #include <time.h>
 
@@ -60,6 +59,7 @@ static subpicture_t *Filter( filter_t *, mtime_t );
 
 static int FetchRSS( filter_t * );
 static void FreeRSS( filter_t * );
+static int ParseUrls( filter_t *, char * );
 
 static const int pi_color_values[] = {
                0xf0000000, 0x00000000, 0x00808080, 0x00C0C0C0,
@@ -77,15 +77,16 @@ static const char *const ppsz_color_descriptions[] = {
  * filter_sys_t: rss filter descriptor
  *****************************************************************************/
 
-struct rss_item_t
+typedef struct rss_item_t
 {
     char *psz_title;
     char *psz_description;
     char *psz_link;
-};
+} rss_item_t;
 
-struct rss_feed_t
+typedef struct rss_feed_t
 {
+    char *psz_url;
     char *psz_title;
     char *psz_description;
     char *psz_link;
@@ -93,8 +94,8 @@ struct rss_feed_t
     picture_t *p_pic;
 
     int i_items;
-    struct rss_item_t *p_items;
-};
+    rss_item_t *p_items;
+} rss_feed_t;
 
 struct filter_sys_t
 {
@@ -112,9 +113,8 @@ struct filter_sys_t
 
     mtime_t last_date;
 
-    char *psz_urls;
     int i_feeds;
-    struct rss_feed_t *p_feeds;
+    rss_feed_t *p_feeds;
 
     int i_ttl;
     time_t t_last_update;
@@ -127,7 +127,7 @@ struct filter_sys_t
 };
 
 #define MSG_TEXT N_("Feed URLs")
-#define MSG_LONGTEXT N_("RSS/Atom feed '|' (pipe) seperated URLs.")
+#define MSG_LONGTEXT N_("RSS/Atom feed '|' (pipe) separated URLs.")
 #define SPEED_TEXT N_("Speed of feeds")
 #define SPEED_LONGTEXT N_("Speed of the RSS/Atom feeds in microseconds (bigger is slower).")
 #define LENGTH_TEXT N_("Max length")
@@ -186,43 +186,43 @@ static const char *const ppsz_title_modes[] =
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_capability( "sub filter", 1 );
-    set_shortname( "RSS / Atom" );
-    set_callbacks( CreateFilter, DestroyFilter );
-    set_category( CAT_VIDEO );
-    set_subcategory( SUBCAT_VIDEO_SUBPIC );
-    add_string( CFG_PREFIX "urls", "rss", NULL, MSG_TEXT, MSG_LONGTEXT, false );
-
-    set_section( N_("Position"), NULL );
-    add_integer( CFG_PREFIX "x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, true );
-    add_integer( CFG_PREFIX "y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, true );
-    add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false );
-        change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL );
-
-    set_section( N_("Font"), NULL );
+vlc_module_begin ()
+    set_capability( "sub filter", 1 )
+    set_shortname( "RSS / Atom" )
+    set_callbacks( CreateFilter, DestroyFilter )
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_SUBPIC )
+    add_string( CFG_PREFIX "urls", "rss", NULL, MSG_TEXT, MSG_LONGTEXT, false )
+
+    set_section( N_("Position"), NULL )
+    add_integer( CFG_PREFIX "x", 0, NULL, POSX_TEXT, POSX_LONGTEXT, true )
+    add_integer( CFG_PREFIX "y", 0, NULL, POSY_TEXT, POSY_LONGTEXT, true )
+    add_integer( CFG_PREFIX "position", -1, NULL, POS_TEXT, POS_LONGTEXT, false )
+        change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL )
+
+    set_section( N_("Font"), NULL )
     /* 5 sets the default to top [1] left [4] */
     add_integer_with_range( CFG_PREFIX "opacity", 255, 0, 255, NULL,
-        OPACITY_TEXT, OPACITY_LONGTEXT, false );
+        OPACITY_TEXT, OPACITY_LONGTEXT, false )
     add_integer( CFG_PREFIX "color", 0xFFFFFF, NULL, COLOR_TEXT, COLOR_LONGTEXT,
-                  false );
-        change_integer_list( pi_color_values, ppsz_color_descriptions, NULL );
-    add_integer( CFG_PREFIX "size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, false );
+                  false )
+        change_integer_list( pi_color_values, ppsz_color_descriptions, NULL )
+    add_integer( CFG_PREFIX "size", -1, NULL, SIZE_TEXT, SIZE_LONGTEXT, false )
 
-    set_section( N_("Misc"), NULL );
+    set_section( N_("Misc"), NULL )
     add_integer( CFG_PREFIX "speed", 100000, NULL, SPEED_TEXT, SPEED_LONGTEXT,
-                 false );
+                 false )
     add_integer( CFG_PREFIX "length", 60, NULL, LENGTH_TEXT, LENGTH_LONGTEXT,
-                 false );
-    add_integer( CFG_PREFIX "ttl", 1800, NULL, TTL_TEXT, TTL_LONGTEXT, false );
-    add_bool( CFG_PREFIX "images", 1, NULL, IMAGE_TEXT, IMAGE_LONGTEXT, false );
-    add_integer( CFG_PREFIX "title", default_title, NULL, TITLE_TEXT, TITLE_LONGTEXT, false );
-        change_integer_list( pi_title_modes, ppsz_title_modes, NULL );
+                 false )
+    add_integer( CFG_PREFIX "ttl", 1800, NULL, TTL_TEXT, TTL_LONGTEXT, false )
+    add_bool( CFG_PREFIX "images", 1, NULL, IMAGE_TEXT, IMAGE_LONGTEXT, false )
+    add_integer( CFG_PREFIX "title", default_title, NULL, TITLE_TEXT, TITLE_LONGTEXT, false )
+        change_integer_list( pi_title_modes, ppsz_title_modes, NULL )
 
-    set_description( N_("RSS and Atom feed display") );
-    add_shortcut( "rss" );
-    add_shortcut( "atom" );
-vlc_module_end();
+    set_description( N_("RSS and Atom feed display") )
+    add_shortcut( "rss" )
+    add_shortcut( "atom" )
+vlc_module_end ()
 
 static const char *const ppsz_filter_options[] = {
     "urls", "x", "y", "position", "color", "size", "speed", "length",
@@ -237,19 +237,18 @@ static int CreateFilter( vlc_object_t *p_this )
     filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys;
     int i_feed;
+    int i_ret = VLC_ENOMEM;
+    char *psz_urls;
 
     /* Allocate structure */
     p_sys = p_filter->p_sys = malloc( sizeof( filter_sys_t ) );
     if( p_sys == NULL )
         return VLC_ENOMEM;
 
-    vlc_mutex_init( &p_sys->lock );
-    vlc_mutex_lock( &p_sys->lock );
-
     config_ChainParse( p_filter, CFG_PREFIX, ppsz_filter_options,
                        p_filter->p_cfg );
 
-    p_sys->psz_urls = var_CreateGetString( p_filter, CFG_PREFIX "urls" );
+    psz_urls = var_CreateGetString( p_filter, CFG_PREFIX "urls" );
     p_sys->i_title = var_CreateGetInteger( p_filter, CFG_PREFIX "title" );
     p_sys->i_cur_feed = 0;
     p_sys->i_cur_item = p_sys->i_title == scroll_title ? -1 : 0;
@@ -261,28 +260,14 @@ static int CreateFilter( vlc_object_t *p_this )
     p_sys->i_ttl = __MAX( 0, var_CreateGetInteger( p_filter, CFG_PREFIX "ttl" ) );
     p_sys->b_images = var_CreateGetBool( p_filter, CFG_PREFIX "images" );
 
-    p_sys->psz_marquee = (char *)malloc( p_sys->i_length + 1 );
+    p_sys->psz_marquee = malloc( p_sys->i_length + 1 );
     if( p_sys->psz_marquee == NULL )
-    {
-        vlc_mutex_unlock( &p_sys->lock );
-        vlc_mutex_destroy( &p_sys->lock );
-        free( p_sys->psz_urls );
-        free( p_sys );
-        return VLC_ENOMEM;
-    }
+        goto error;
     p_sys->psz_marquee[p_sys->i_length] = '\0';
 
-    p_sys->p_style = malloc( sizeof( text_style_t ));
+    p_sys->p_style = text_style_New();
     if( p_sys->p_style == NULL )
-    {
-        free( p_sys->psz_marquee );
-        vlc_mutex_unlock( &p_sys->lock );
-        vlc_mutex_destroy( &p_sys->lock );
-        free( p_sys->psz_urls );
-        free( p_sys );
-        return VLC_ENOMEM;
-    }
-    memcpy( p_sys->p_style, &default_text_style, sizeof( text_style_t ));
+        goto error;
 
     p_sys->i_xoff = var_CreateGetInteger( p_filter, CFG_PREFIX "x" );
     p_sys->i_yoff = var_CreateGetInteger( p_filter, CFG_PREFIX "y" );
@@ -296,50 +281,45 @@ static int CreateFilter( vlc_object_t *p_this )
         msg_Warn( p_filter, "rss-size wasn't specified. Feed images will thus be displayed without being resized" );
     }
 
+    /* Parse the urls */
+    ParseUrls( p_filter, psz_urls );
+    free( psz_urls );
+
     if( FetchRSS( p_filter ) )
     {
         msg_Err( p_filter, "failed while fetching RSS ... too bad" );
-        free( p_sys->p_style );
-        free( p_sys->psz_marquee );
-        vlc_mutex_unlock( &p_sys->lock );
-        vlc_mutex_destroy( &p_sys->lock );
-        free( p_sys->psz_urls );
-        free( p_sys );
-        return VLC_EGENERIC;
+        text_style_Delete( p_sys->p_style );
+        i_ret = VLC_EGENERIC;
+        goto error;
     }
     p_sys->t_last_update = time( NULL );
 
     if( p_sys->i_feeds == 0 )
     {
-        free( p_sys->p_style );
-        free( p_sys->psz_marquee );
-        vlc_mutex_unlock( &p_sys->lock );
-        vlc_mutex_destroy( &p_sys->lock );
-        free( p_sys->psz_urls );
-        free( p_sys );
-        return VLC_EGENERIC;
+        text_style_Delete( p_sys->p_style );
+        i_ret = VLC_EGENERIC;
+        goto error;
     }
     for( i_feed=0; i_feed < p_sys->i_feeds; i_feed ++ )
     {
         if( p_sys->p_feeds[i_feed].i_items == 0 )
         {
-            free( p_sys->p_style );
-            free( p_sys->psz_marquee );
-            FreeRSS( p_filter );
-            vlc_mutex_unlock( &p_sys->lock );
-            vlc_mutex_destroy( &p_sys->lock );
-            free( p_sys->psz_urls );
-            free( p_sys );
+            DestroyFilter( p_this );
             return VLC_EGENERIC;
         }
     }
+
     /* Misc init */
+    vlc_mutex_init( &p_sys->lock );
     p_filter->pf_sub_filter = Filter;
     p_sys->last_date = (mtime_t)0;
 
-    vlc_mutex_unlock( &p_sys->lock );
-
     return VLC_SUCCESS;
+
+error:
+    free( p_sys->psz_marquee );
+    free( p_sys );
+    return i_ret;
 }
 /*****************************************************************************
  * DestroyFilter: destroy RSS video filter
@@ -349,29 +329,10 @@ static void DestroyFilter( vlc_object_t *p_this )
     filter_t *p_filter = (filter_t *)p_this;
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    vlc_mutex_lock( &p_sys->lock );
-
-    free( p_sys->p_style );
+    text_style_Delete( p_sys->p_style );
     free( p_sys->psz_marquee );
-    free( p_sys->psz_urls );
     FreeRSS( p_filter );
-    vlc_mutex_unlock( &p_sys->lock );
-    vlc_mutex_destroy( &p_sys->lock );
     free( p_sys );
-
-    /* Delete the RSS variables */
-    var_Destroy( p_filter, CFG_PREFIX "urls" );
-    var_Destroy( p_filter, CFG_PREFIX "speed" );
-    var_Destroy( p_filter, CFG_PREFIX "length" );
-    var_Destroy( p_filter, CFG_PREFIX "ttl" );
-    var_Destroy( p_filter, CFG_PREFIX "images" );
-    var_Destroy( p_filter, CFG_PREFIX "x" );
-    var_Destroy( p_filter, CFG_PREFIX "y" );
-    var_Destroy( p_filter, CFG_PREFIX "position" );
-    var_Destroy( p_filter, CFG_PREFIX "color");
-    var_Destroy( p_filter, CFG_PREFIX "opacity");
-    var_Destroy( p_filter, CFG_PREFIX "size");
-    var_Destroy( p_filter, CFG_PREFIX "title" );
 }
 
 /****************************************************************************
@@ -387,8 +348,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
     subpicture_region_t *p_region;
 
     int i_feed, i_item;
-
-    struct rss_feed_t *p_feed;
+    rss_feed_t *p_feed;
 
     memset( &fmt, 0, sizeof(video_format_t) );
 
@@ -441,9 +401,9 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
         return NULL;
     }
 
-    fmt.i_chroma = VLC_FOURCC('T','E','X','T');
+    fmt.i_chroma = VLC_CODEC_TEXT;
 
-    p_spu->p_region = p_spu->pf_create_region( VLC_OBJECT(p_filter), &fmt );
+    p_spu->p_region = subpicture_region_New( &fmt );
     if( !p_spu->p_region )
     {
         p_filter->pf_sub_buffer_del( p_filter, p_spu );
@@ -530,10 +490,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
         p_spu->b_absolute = false;
     }
 
-    p_spu->i_x = p_sys->i_xoff;
-    p_spu->i_y = p_sys->i_yoff;
-
-    p_spu->p_region->p_style = p_sys->p_style;
+    p_spu->p_region->p_style = text_style_Duplicate( p_sys->p_style );
 
     if( p_feed->p_pic )
     {
@@ -543,7 +500,7 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
 
         memset( &fmt_out, 0, sizeof(video_format_t) );
 
-        fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
+        fmt_out.i_chroma = VLC_CODEC_YUVA;
         fmt_out.i_aspect = VOUT_ASPECT_FACTOR;
         fmt_out.i_sar_num = fmt_out.i_sar_den = 1;
         fmt_out.i_width =
@@ -551,14 +508,17 @@ static subpicture_t *Filter( filter_t *p_filter, mtime_t date )
         fmt_out.i_height =
             fmt_out.i_visible_height = p_pic->p[Y_PLANE].i_visible_lines;
 
-        p_region = p_spu->pf_create_region( VLC_OBJECT( p_filter ), &fmt_out );
+        p_region = subpicture_region_New( &fmt_out );
         if( !p_region )
         {
             msg_Err( p_filter, "cannot allocate SPU region" );
         }
         else
         {
-            vout_CopyPicture( p_filter, &p_region->picture, p_pic );
+            p_region->i_x = p_sys->i_xoff;
+            p_region->i_y = p_sys->i_yoff;
+            /* FIXME the copy is probably not needed anymore */
+            picture_Copy( p_region->p_picture, p_pic );
             p_spu->p_region->p_next = p_region;
         }
 
@@ -594,7 +554,7 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
     memset( &fmt_in, 0, sizeof(video_format_t) );
     memset( &fmt_out, 0, sizeof(video_format_t) );
 
-    fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
+    fmt_out.i_chroma = VLC_CODEC_YUVA;
     p_orig = image_ReadUrl( p_handler, psz_url, &fmt_in, &fmt_out );
 
     if( !p_orig )
@@ -604,7 +564,7 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
     else if( p_sys->p_style->i_font_size > 0 )
     {
 
-        fmt_in.i_chroma = VLC_FOURCC('Y','U','V','A');
+        fmt_in.i_chroma = VLC_CODEC_YUVA;
         fmt_in.i_height = p_orig->p[Y_PLANE].i_visible_lines;
         fmt_in.i_width = p_orig->p[Y_PLANE].i_visible_pitch;
         fmt_out.i_width = p_orig->p[Y_PLANE].i_visible_pitch
@@ -632,12 +592,12 @@ static picture_t *LoadImage( filter_t *p_filter, const char *psz_url )
  * remove all ' ' '\t' '\n' '\r' characters from the begining and end of the
  * string.
  ***************************************************************************/
-static char *removeWhiteChars( char *psz_src )
+static char *removeWhiteChars( const char *psz_src )
 {
-    char *psz_src2 = strdup( psz_src );
-    char *psz_clean = strdup( psz_src2 );
-    char *psz_clean2;
+    char *psz_src2,*psz_clean, *psz_clean2;
+    psz_src2 = psz_clean = strdup( psz_src );
     int i;
+
     while( ( *psz_clean == ' ' || *psz_clean == '\t'
            || *psz_clean == '\n' || *psz_clean == '\r' )
            && *psz_clean != '\0' )
@@ -654,6 +614,61 @@ static char *removeWhiteChars( char *psz_src )
     return psz_clean2;
 }
 
+
+/****************************************************************************
+ * Parse url list, psz_urls must be non empty
+ ***************************************************************************/
+static int ParseUrls( filter_t *p_filter, char *psz_urls )
+{
+    filter_sys_t *p_sys = p_filter->p_sys;
+    char *psz_urls2 = psz_urls;
+
+    p_sys->i_feeds = 1;
+
+    /* Count the number of feeds */
+    while( *psz_urls )
+    {
+        if( *psz_urls == '|' )
+            p_sys->i_feeds++;
+        psz_urls++;
+    }
+
+    /* Allocate the structure */
+    p_sys->p_feeds = malloc( p_sys->i_feeds * sizeof( rss_feed_t ) );
+    if( !p_sys->p_feeds )
+        return VLC_ENOMEM;
+
+    /* Loop on all urls and fill in the struct */
+    psz_urls = psz_urls2;
+    for( int i = 0; i < p_sys->i_feeds; i++ )
+    {
+        rss_feed_t* p_feed = p_sys->p_feeds + i;
+        char *psz_end;
+
+        if( i < p_sys->i_feeds - 1 )
+        {
+            psz_end = strchr( psz_urls, '|' );
+            *psz_end = '\0';
+        }
+        else
+            psz_end = psz_urls;
+
+        p_feed->i_items = 0;
+        p_feed->p_items = NULL;
+        p_feed->psz_title = NULL;
+        p_feed->psz_link = NULL;
+        p_feed->psz_description = NULL;
+        p_feed->psz_image = NULL;
+        p_feed->p_pic = NULL;
+        p_feed->psz_url = strdup( psz_urls );
+
+        psz_urls = psz_end + 1;
+    }
+
+    return VLC_SUCCESS;
+}
+
+
 /****************************************************************************
  * FetchRSS (or Atom) feeds
  ***************************************************************************/
@@ -667,24 +682,11 @@ static int FetchRSS( filter_t *p_filter)
 
     char *psz_eltname = NULL;
     char *psz_eltvalue = NULL;
-    char *psz_feed = NULL;
-    char *psz_buffer = NULL;
-    char *psz_buffer_2 = NULL;
 
     int i_feed;
     int i_item;
     bool b_is_item;
     bool b_is_image;
-    int i_int;
-
-    FreeRSS( p_filter );
-    p_sys->i_feeds = 1;
-    i_int = 0;
-    while( p_sys->psz_urls[i_int] != 0 )
-        if( p_sys->psz_urls[i_int++] == '|' )
-            p_sys->i_feeds++;
-    p_sys->p_feeds = (struct rss_feed_t *)malloc( p_sys->i_feeds
-                                * sizeof( struct rss_feed_t ) );
 
     p_xml = xml_Create( p_filter );
     if( !p_xml )
@@ -693,39 +695,44 @@ static int FetchRSS( filter_t *p_filter)
         return 1;
     }
 
-    psz_buffer = strdup( p_sys->psz_urls );
-    psz_buffer_2 = psz_buffer; /* keep track so we can free it */
     for( i_feed = 0; i_feed < p_sys->i_feeds; i_feed++ )
     {
-        struct rss_feed_t *p_feed = p_sys->p_feeds+i_feed;
-
-        if( psz_buffer == NULL ) break;
-        if( psz_buffer[0] == 0 ) psz_buffer++;
-        psz_feed = psz_buffer;
-        psz_buffer = strchr( psz_buffer, '|' );
-        if( psz_buffer != NULL ) psz_buffer[0] = 0;
+        rss_feed_t *p_feed = p_sys->p_feeds+i_feed;
 
-        p_feed->psz_title = NULL;
-        p_feed->psz_description = NULL;
-        p_feed->psz_link = NULL;
-        p_feed->psz_image = NULL;
-        p_feed->p_pic = NULL;
+        FREENULL( p_feed->psz_title );
+        FREENULL( p_feed->psz_description );
+        FREENULL( p_feed->psz_link );
+        FREENULL( p_feed->psz_image );
+        if( p_feed->p_pic )
+        {
+            picture_Release( p_feed->p_pic );
+            p_feed->p_pic = NULL;
+        }
+        for( int i = 0; i < p_feed->i_items; i++ )
+        {
+            rss_item_t *p_item = p_feed->p_items + i;
+            free( p_item->psz_title );
+            free( p_item->psz_link );
+            free( p_item->psz_description );
+        }
         p_feed->i_items = 0;
-        p_feed->p_items = NULL;
+        FREENULL( p_feed->p_items );
 
-        msg_Dbg( p_filter, "opening %s RSS/Atom feed ...", psz_feed );
+        msg_Dbg( p_filter, "opening %s RSS/Atom feed ...", p_feed->psz_url );
 
-        p_stream = stream_UrlNew( p_filter, psz_feed );
+        p_stream = stream_UrlNew( p_filter, p_feed->psz_url );
         if( !p_stream )
         {
-            msg_Err( p_filter, "Failed to open %s for reading", psz_feed );
+            msg_Err( p_filter, "Failed to open %s for reading", p_feed->psz_url );
+            xml_Delete( p_xml );
             return 1;
         }
 
         p_xml_reader = xml_ReaderCreate( p_xml, p_stream );
         if( !p_xml_reader )
         {
-            msg_Err( p_filter, "Failed to open %s for parsing", psz_feed );
+            msg_Err( p_filter, "Failed to open %s for parsing", p_feed->psz_url );
+            xml_Delete( p_xml );
             return 1;
         }
 
@@ -756,7 +763,7 @@ static int FetchRSS( filter_t *p_filter)
                     {
                         b_is_item = true;
                         p_feed->i_items++;
-                        p_feed->p_items = (struct rss_item_t *)realloc( p_feed->p_items, p_feed->i_items * sizeof( struct rss_item_t ) );
+                        p_feed->p_items = realloc( p_feed->p_items, p_feed->i_items * sizeof( rss_item_t ) );
                         p_feed->p_items[p_feed->i_items-1].psz_title = NULL;
                         p_feed->p_items[p_feed->i_items-1].psz_description
                                                                      = NULL;
@@ -873,8 +880,7 @@ static int FetchRSS( filter_t *p_filter)
 #                   endif
                     if( b_is_item == true )
                     {
-                        struct rss_item_t *p_item;
-                        p_item = p_feed->p_items+i_item;
+                        rss_item_t *p_item = p_feed->p_items+i_item;
                         if( !strcmp( psz_eltname, "title" ) /* rss/atom */
                             && !p_item->psz_title )
                         {
@@ -952,9 +958,8 @@ static int FetchRSS( filter_t *p_filter)
 
         if( p_xml_reader && p_xml ) xml_ReaderDelete( p_xml, p_xml_reader );
         if( p_stream ) stream_Delete( p_stream );
-        msg_Dbg( p_filter, "done with %s RSS/Atom feed", psz_feed );
+        msg_Dbg( p_filter, "done with %s RSS/Atom feed", p_feed->psz_url );
     }
-    free( psz_buffer_2 );
     if( p_xml ) xml_Delete( p_xml );
 
     return 0;
@@ -967,18 +972,12 @@ static void FreeRSS( filter_t *p_filter)
 {
     filter_sys_t *p_sys = p_filter->p_sys;
 
-    struct rss_item_t *p_item;
-    struct rss_feed_t *p_feed;
-
-    int i_feed;
-    int i_item;
-
-    for( i_feed = 0; i_feed < p_sys->i_feeds; i_feed++ )
+    for( int i_feed = 0; i_feed < p_sys->i_feeds; i_feed++ )
     {
-        p_feed = p_sys->p_feeds+i_feed;
-        for( i_item = 0; i_item < p_feed->i_items; i_item++ )
+        rss_feed_t *p_feed = p_sys->p_feeds+i_feed;
+        for( int i_item = 0; i_item < p_feed->i_items; i_item++ )
         {
-            p_item = p_feed->p_items+i_item;
+            rss_item_t *p_item = p_feed->p_items+i_item;
             free( p_item->psz_title );
             free( p_item->psz_link );
             free( p_item->psz_description );
@@ -990,6 +989,7 @@ static void FreeRSS( filter_t *p_filter)
         free( p_feed->psz_image );
         if( p_feed->p_pic != NULL )
             picture_Release( p_feed->p_pic );
+        free( p_feed->psz_url );
     }
     free( p_sys->p_feeds );
     p_sys->i_feeds = 0;