[vlc-devel] commit: playlist demux: no need to strdup the string here. ( Rémi Duraffort )

git version control git at videolan.org
Mon Aug 17 14:36:04 CEST 2009


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Sun Aug 16 17:32:46 2009 +0200| [1938cc4e9c3a8f20f341ea3949c344699b7c046d] | committer: Rémi Duraffort 

playlist demux: no need to strdup the string here.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1938cc4e9c3a8f20f341ea3949c344699b7c046d
---

 modules/demux/playlist/b4s.c  |   20 ++++++++++----------
 modules/demux/playlist/xspf.c |   10 ++++++----
 2 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/modules/demux/playlist/b4s.c b/modules/demux/playlist/b4s.c
index 31405b4..acf5d9b 100644
--- a/modules/demux/playlist/b4s.c
+++ b/modules/demux/playlist/b4s.c
@@ -200,15 +200,15 @@ static int Demux( demux_t *p_demux )
                     if( !strcmp( psz_elname, "entry" ) &&
                         !strcmp( psz_name, "Playstring" ) )
                     {
-                        psz_mrl = strdup( psz_value );
+                        psz_mrl = psz_value;
                     }
                     else
                     {
                         msg_Warn( p_demux, "unexpected attribure %s in element %s",
                                   psz_name, psz_elname );
+                        free( psz_value );
                     }
                     free( psz_name );
-                    free( psz_value );
                 }
                 break;
             }
@@ -222,34 +222,34 @@ static int Demux( demux_t *p_demux )
                 }
                 if( !strcmp( psz_elname, "Name" ) )
                 {
-                    psz_name = strdup( psz_text );
+                    psz_name = psz_text;
                 }
                 else if( !strcmp( psz_elname, "Genre" ) )
                 {
-                    psz_genre = strdup( psz_text );
+                    psz_genre = psz_text;
                 }
                 else if( !strcmp( psz_elname, "Nowplaying" ) )
                 {
-                    psz_now = strdup( psz_text );
+                    psz_now = psz_text;
                 }
                 else if( !strcmp( psz_elname, "Listeners" ) )
                 {
-                    psz_listeners = strdup( psz_text );
+                    psz_listeners = psz_text;
                 }
                 else if( !strcmp( psz_elname, "Bitrate" ) )
                 {
-                    psz_bitrate = strdup( psz_text );
+                    psz_bitrate = psz_text;
                 }
                 else if( !strcmp( psz_elname, "" ) )
                 {
-                    ;
+                    free( psz_text );
                 }
                 else
                 {
                     msg_Warn( p_demux, "unexpected text in element '%s'",
                               psz_elname );
+                    free( psz_text );
                 }
-                free( psz_text );
                 break;
             }
             // End element
@@ -281,7 +281,7 @@ static int Demux( demux_t *p_demux )
                     FREENULL( psz_now );
                 }
                 free( psz_elname );
-                psz_elname = strdup("");
+                psz_elname = strdup( "" );
 
                 break;
             }
diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index d79e874..705949c 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -716,19 +716,21 @@ static bool parse_extension_node COMPLEX_INTERFACE
         if( !strcmp( psz_name, "title" ) )
         {
             resolve_xml_special_chars( psz_value );
-            psz_title = strdup( psz_value );
+            psz_title = psz_value;
         }
         /* extension attribute: application */
         else if( !strcmp( psz_name, "application" ) )
         {
-            psz_application = strdup( psz_value );
+            psz_application = psz_value;
         }
         /* unknown attribute */
         else
+        {
             msg_Warn( p_demux, "invalid <%s> attribute:\"%s\"", psz_element,
                       psz_name );
-
-        FREE_ATT();
+            FREE_VALUE();
+        }
+        FREE_NAME();
     }
 
     /* attribute title is mandatory except for <extension> */




More information about the vlc-devel mailing list