]> git.sesse.net Git - vlc/commitdiff
* src/input/input.c: fixed memleaks.
authorGildas Bazin <gbazin@videolan.org>
Thu, 15 Jan 2004 23:40:44 +0000 (23:40 +0000)
committerGildas Bazin <gbazin@videolan.org>
Thu, 15 Jan 2004 23:40:44 +0000 (23:40 +0000)
* src/input/input_info.c: small bug fix.
* modules/stream_out/standard.c: fixed memleaks.

modules/stream_out/standard.c
src/input/input.c
src/input/input_info.c

index 84231e58913787a84b07d22215775a5dd149339c..069261247f14eaa4bf2f8c706679f2a983ae855b 100644 (file)
@@ -2,7 +2,7 @@
  * standard.c
  *****************************************************************************
  * Copyright (C) 2001, 2002 VideoLAN
- * $Id: standard.c,v 1.16 2003/11/21 15:32:08 fenrir Exp $
+ * $Id: standard.c,v 1.17 2004/01/15 23:40:44 gbazin Exp $
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  *
@@ -69,7 +69,8 @@ static int Open( vlc_object_t *p_this )
 {
     sout_stream_t       *p_stream = (sout_stream_t*)p_this;
     sout_instance_t     *p_sout = p_stream->p_sout;
-    sout_stream_sys_t   *p_sys = malloc( sizeof( sout_stream_sys_t) );
+    slp_session_t       *p_slp = NULL;
+    sap_session_t       *p_sap = NULL;
 
     char *psz_mux      = sout_cfg_find_value( p_stream->p_cfg, "mux" );
     char *psz_access   = sout_cfg_find_value( p_stream->p_cfg, "access" );
@@ -87,9 +88,6 @@ static int Open( vlc_object_t *p_this )
 
     char                *psz_mux_byext = NULL;
 
-    p_sys->p_sap = NULL;
-    p_sys->p_slp = NULL;
-
     msg_Dbg( p_this, "creating `%s/%s://%s'",
              psz_access, psz_mux, psz_url );
 
@@ -257,11 +255,11 @@ static int Open( vlc_object_t *p_this )
         }
         msg_Dbg( p_sout , "Creating SAP with IPv%i", atoi(psz_ipv) );
 
-        p_sys->p_sap = sout_SAPNew( p_sout , psz_url ,
+        p_sap = sout_SAPNew( p_sout , psz_url ,
             p_sap_cfg->psz_value ? p_sap_cfg->psz_value : psz_url,
             atoi(psz_ipv), psz_v6_scope );
 
-        if( !p_sys->p_sap )
+        if( !p_sap )
             msg_Err( p_sout,"Unable to initialize SAP. SAP disabled");
     }
 
@@ -278,14 +276,15 @@ static int Open( vlc_object_t *p_this )
         }
         else
         {
-            p_sys->p_slp = (slp_session_t*)malloc(sizeof(slp_session_t));
-            if(!p_sys->p_slp)
+            p_slp = (slp_session_t*)malloc(sizeof(slp_session_t));
+            if(!p_slp)
             {
                 msg_Warn(p_sout,"Out of memory");
+                if( p_sap ) free( p_sap );
                 return -1;
             }
-            p_sys->p_slp->psz_url= strdup(psz_url);
-            p_sys->p_slp->psz_name = strdup(
+            p_slp->psz_url= strdup(psz_url);
+            p_slp->psz_name = strdup(
                     p_slp_cfg->psz_value ? p_slp_cfg->psz_value : psz_url);
         }
     }
@@ -294,14 +293,15 @@ static int Open( vlc_object_t *p_this )
     /* XXX beurk */
     p_sout->i_preheader = __MAX( p_sout->i_preheader, p_mux->i_preheader );
 
-
-    p_sys->p_mux = p_mux;
-
     p_stream->pf_add    = Add;
     p_stream->pf_del    = Del;
     p_stream->pf_send   = Send;
 
-    p_stream->p_sys     = p_sys;
+    p_stream->p_sys        = malloc( sizeof( sout_stream_sys_t) );
+    p_stream->p_sys->p_mux = p_mux;
+    p_stream->p_sys->p_slp = p_slp;
+    p_stream->p_sys->p_sap = p_sap;
+
     return VLC_SUCCESS;
 }
 
index 31cb0d015dc945a1503910854edc22a3224992be..9b0ee9efbe4b7b3e3a7cb75c62f1d033f274483e 100644 (file)
@@ -4,7 +4,7 @@
  * decoders.
  *****************************************************************************
  * Copyright (C) 1998-2004 VideoLAN
- * $Id: input.c,v 1.275 2004/01/10 23:46:39 sigmunau Exp $
+ * $Id: input.c,v 1.276 2004/01/15 23:40:44 gbazin Exp $
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
  *
@@ -85,7 +85,6 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
                                       playlist_item_t *p_item )
 {
     input_thread_t *    p_input;                        /* thread descriptor */
-    input_info_category_t * p_info;
     vlc_value_t val;
     int i,j;
 
@@ -245,23 +244,15 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
     p_input->stream.control.i_status = INIT_S;
     p_input->stream.control.i_rate = DEFAULT_RATE;
     p_input->stream.control.b_mute = 0;
-    p_input->stream.control.b_grayscale = config_GetInt( p_input, "grayscale" );
-
-    /* Initialize input info */
-    p_input->stream.p_info = malloc( sizeof( input_info_category_t ) );
-    if( !p_input->stream.p_info )
-    {
-        msg_Err( p_input, "No memory!" );
-        return NULL;
-    }
-    p_input->stream.p_info->psz_name = strdup("General") ;
-    p_input->stream.p_info->p_info = NULL;
-    p_input->stream.p_info->p_next = NULL;
+    p_input->stream.control.b_grayscale = config_GetInt( p_input, "grayscale");
 
     msg_Info( p_input, "playlist item `%s'", p_input->psz_source );
 
-    p_info = input_InfoCategory( p_input, _("General") );
-    input_AddInfo( p_info, _("Playlist Item"), p_input->psz_source );
+    /* Initialize input info */
+    p_input->stream.p_info = NULL;
+    p_input->stream.p_info = input_InfoCategory( p_input, _("General") );
+    input_AddInfo( p_input->stream.p_info, _("Playlist Item"),
+                   p_input->psz_source );
     vlc_object_attach( p_input, p_parent );
 
     /* Create thread and wait for its readiness. */
@@ -269,6 +260,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
                            VLC_THREAD_PRIORITY_INPUT, VLC_TRUE ) )
     {
         msg_Err( p_input, "cannot create input thread" );
+        input_DelInfo( p_input );
         free( p_input );
         return NULL;
     }
@@ -331,6 +323,8 @@ static int RunThread( input_thread_t *p_input )
         /* Tell we're dead */
         p_input->b_dead = 1;
 
+        input_DelInfo( p_input );
+
         return 0;
     }
 
index bf70d8d42ad31499a992a449cbdcd3e6d7fdad31..e246167f58a110ae8c4ef98ac60c7ed430247d4e 100644 (file)
@@ -2,7 +2,7 @@
  * input_info.c: Convenient functions to handle the input info structures
  *****************************************************************************
  * Copyright (C) 1998-2004 VideoLAN
- * $Id: input_info.c,v 1.12 2004/01/06 12:02:06 zorglub Exp $
+ * $Id: input_info.c,v 1.13 2004/01/15 23:40:44 gbazin Exp $
  *
  * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
  *
@@ -69,7 +69,7 @@ input_info_category_t * input_InfoCategory( input_thread_t * p_input,
         p_category->psz_name = strdup( psz_name );
         p_category->p_next = NULL;
         p_category->p_info = NULL;
-        p_prev->p_next = p_category;
+        if( p_prev ) p_prev->p_next = p_category;
         return p_category;
     }
 }