[vlc-commits] vlc_input: remove unneeded init and add check allocs

Francois Cartegnie git at videolan.org
Sun Nov 22 17:46:34 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Sat Nov 21 20:35:13 2015 +0100| [0efef5cc760fcc2e0eebc700c64dfe4a68c4e462] | committer: Francois Cartegnie

vlc_input: remove unneeded init and add check allocs

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

 include/vlc_input.h |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/include/vlc_input.h b/include/vlc_input.h
index 6399cfb..096d73f 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -71,8 +71,11 @@ static inline void vlc_seekpoint_Delete( seekpoint_t *point )
 static inline seekpoint_t *vlc_seekpoint_Duplicate( const seekpoint_t *src )
 {
     seekpoint_t *point = vlc_seekpoint_New();
-    if( src->psz_name ) point->psz_name = strdup( src->psz_name );
-    point->i_time_offset = src->i_time_offset;
+    if( likely(point) )
+    {
+        if( src->psz_name ) point->psz_name = strdup( src->psz_name );
+        point->i_time_offset = src->i_time_offset;
+    }
     return point;
 }
 
@@ -115,10 +118,7 @@ static inline void vlc_input_title_Delete( input_title_t *t )
 
     free( t->psz_name );
     for( i = 0; i < t->i_seekpoint; i++ )
-    {
-        free( t->seekpoint[i]->psz_name );
-        free( t->seekpoint[i] );
-    }
+        vlc_seekpoint_Delete( t->seekpoint[i] );
     free( t->seekpoint );
     free( t );
 }
@@ -131,15 +131,14 @@ static inline input_title_t *vlc_input_title_Duplicate( const input_title_t *t )
     if( t->psz_name ) dup->psz_name = strdup( t->psz_name );
     dup->b_menu      = t->b_menu;
     dup->i_length    = t->i_length;
-    dup->i_seekpoint = t->i_seekpoint;
     if( t->i_seekpoint > 0 )
     {
-        dup->seekpoint = (seekpoint_t**)calloc( t->i_seekpoint,
-                                                sizeof(seekpoint_t*) );
-
-        for( i = 0; i < t->i_seekpoint; i++ )
+        dup->seekpoint = (seekpoint_t**)malloc( t->i_seekpoint * sizeof(seekpoint_t*) );
+        if( likely(dup->seekpoint) )
         {
-            dup->seekpoint[i] = vlc_seekpoint_Duplicate( t->seekpoint[i] );
+            for( i = 0; i < t->i_seekpoint; i++ )
+                dup->seekpoint[i] = vlc_seekpoint_Duplicate( t->seekpoint[i] );
+            dup->i_seekpoint = t->i_seekpoint;
         }
     }
 



More information about the vlc-commits mailing list