Const as usual
authorRémi Denis-Courmont <rem@videolan.org>
Wed, 8 Nov 2006 16:23:33 +0000 (16:23 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Wed, 8 Nov 2006 16:23:33 +0000 (16:23 +0000)
include/vlc_access.h
include/vlc_symbols.h
src/input/access.c
src/input/input.c
src/input/input_internal.h

index a16f70c..b1326d1 100644 (file)
@@ -110,8 +110,8 @@ struct access_t
 };
 
 #define access2_New( a, b, c, d, e ) __access2_New(VLC_OBJECT(a), b, c, d, e )
-VLC_EXPORT( access_t *, __access2_New,  ( vlc_object_t *p_obj, char *psz_access, char *psz_demux, char *psz_path, vlc_bool_t b_quick ) );
-VLC_EXPORT( access_t *, access2_FilterNew, ( access_t *p_source, char *psz_access_filter ) );
+VLC_EXPORT( access_t *, __access2_New,  ( vlc_object_t *p_obj, const char *psz_access, const char *psz_demux, const char *psz_path, vlc_bool_t b_quick ) );
+VLC_EXPORT( access_t *, access2_FilterNew, ( access_t *p_source, const char *psz_access_filter ) );
 VLC_EXPORT( void,      access2_Delete, ( access_t * ) );
 
 static inline int access2_vaControl( access_t *p_access, int i_query, va_list args )
index d69cd37..9137277 100644 (file)
@@ -159,8 +159,8 @@ struct module_symbols_t
     void * (*vout_RequestWindow_inner) (vout_thread_t *, int *, int *, unsigned int *, unsigned int *);
     void (*vout_ReleaseWindow_inner) (vout_thread_t *, void *);
     int (*vout_ControlWindow_inner) (vout_thread_t *, void *, int, va_list);
-    access_t * (*__access2_New_inner) (vlc_object_t *p_obj, char *psz_access, char *psz_demux, char *psz_path, vlc_bool_t b_quick);
-    access_t * (*access2_FilterNew_inner) (access_t *p_source, char *psz_access_filter);
+    access_t * (*__access2_New_inner) (vlc_object_t *p_obj, const char *psz_access, const char *psz_demux, const char *psz_path, vlc_bool_t b_quick);
+    access_t * (*access2_FilterNew_inner) (access_t *p_source, const char *psz_access_filter);
     void (*access2_Delete_inner) (access_t *);
     block_t * (*__block_New_inner) (vlc_object_t *, int);
     block_t * (*block_Realloc_inner) (block_t *, int i_pre, int i_body);
index 394bf98..43d143d 100644 (file)
@@ -30,8 +30,8 @@
 /*****************************************************************************
  * access2_InternalNew:
  *****************************************************************************/
-static access_t *access2_InternalNew( vlc_object_t *p_obj, char *psz_access,
-                                      char *psz_demux, char *psz_path,
+static access_t *access2_InternalNew( vlc_object_t *p_obj, const char *psz_access,
+                                      const char *psz_demux, const char *psz_path,
                                       access_t *p_source, vlc_bool_t b_quick )
 {
     access_t *p_access = vlc_object_create( p_obj, VLC_OBJECT_ACCESS );
@@ -108,8 +108,8 @@ static access_t *access2_InternalNew( vlc_object_t *p_obj, char *psz_access,
 /*****************************************************************************
  * access2_New:
  *****************************************************************************/
-access_t *__access2_New( vlc_object_t *p_obj, char *psz_access,
-                         char *psz_demux, char *psz_path, vlc_bool_t b_quick )
+access_t *__access2_New( vlc_object_t *p_obj, const char *psz_access,
+                         const char *psz_demux, const char *psz_path, vlc_bool_t b_quick )
 {
     return access2_InternalNew( p_obj, psz_access, psz_demux,
                                 psz_path, NULL, b_quick );
@@ -118,7 +118,7 @@ access_t *__access2_New( vlc_object_t *p_obj, char *psz_access,
 /*****************************************************************************
  * access2_FilterNew:
  *****************************************************************************/
-access_t *access2_FilterNew( access_t *p_source, char *psz_access_filter )
+access_t *access2_FilterNew( access_t *p_source, const char *psz_access_filter )
 {
     return access2_InternalNew( VLC_OBJECT(p_source), psz_access_filter,
                                 NULL, NULL, p_source, VLC_FALSE );
index 790bd63..084ce04 100644 (file)
@@ -74,7 +74,7 @@ static void MRLSections( input_thread_t *, char *, int *, int *, int *, int *);
 
 static input_source_t *InputSourceNew( input_thread_t *);
 static int  InputSourceInit( input_thread_t *, input_source_t *,
-                             char *, const char *psz_forced_demux );
+                             const char *, const char *psz_forced_demux );
 static void InputSourceClean( input_thread_t *, input_source_t * );
 
 static void SlaveDemux( input_thread_t *p_input );
@@ -1921,17 +1921,19 @@ static input_source_t *InputSourceNew( input_thread_t *p_input )
  * InputSourceInit:
  *****************************************************************************/
 static int InputSourceInit( input_thread_t *p_input,
-                            input_source_t *in, char *psz_mrl,
+                            input_source_t *in, const char *psz_mrl,
                             const char *psz_forced_demux )
 {
-    char *psz_dup = strdup( psz_mrl );
-    char *psz_access;
-    char *psz_demux;
+    char psz_dup[strlen (psz_mrl) + 1];
+    const char *psz_access;
+    const char *psz_demux;
     char *psz_path;
     char *psz_tmp;
     char *psz;
     vlc_value_t val;
 
+    strcpy (psz_dup, psz_mrl);
+
     if( !in ) return VLC_EGENERIC;
     if( !p_input ) return VLC_EGENERIC;
 
@@ -1986,7 +1988,7 @@ static int InputSourceInit( input_thread_t *p_input,
     }
     else
     {
-        psz_path = psz_mrl;
+        psz_path = psz_dup;
         msg_Dbg( p_input, "trying to pre-parse %s",  psz_path );
         psz_demux = "";
         psz_access = "file";
@@ -2048,8 +2050,7 @@ static int InputSourceInit( input_thread_t *p_input,
         if( in->p_access == NULL &&
             *psz_access == '\0' && ( *psz_demux || *psz_path ) )
         {
-            if( psz_dup ) free( psz_dup );
-            psz_dup = strdup( psz_mrl );
+            strcpy (psz_dup, psz_mrl);
             psz_access = "";
             if( psz_forced_demux && *psz_forced_demux )
             {
@@ -2170,7 +2171,6 @@ static int InputSourceInit( input_thread_t *p_input,
     if( var_GetInteger( p_input, "clock-synchro" ) != -1 )
         in->b_can_pace_control = !var_GetInteger( p_input, "clock-synchro" );
 
-    if( psz_dup ) free( psz_dup );
     return VLC_SUCCESS;
 
 error:
@@ -2184,7 +2184,6 @@ error:
 
     if( in->p_access )
         access2_Delete( in->p_access );
-    if( psz_dup ) free( psz_dup );
 
     return VLC_EGENERIC;
 }
@@ -2326,11 +2325,11 @@ static void InputMetaUser( input_thread_t *p_input )
  *****************************************************************************/
 void MRLSplit( vlc_object_t *p_input, char *psz_dup,
                const char **ppsz_access, const char **ppsz_demux,
-               const char **ppsz_path )
+               char **ppsz_path )
 {
-    char *psz_access = NULL;
-    char *psz_demux  = NULL;
-    char *psz_path   = NULL;
+    const char *psz_access = "";
+    const char *psz_demux  = "";
+    char *psz_path;
     char *psz, *psz_check;
 
     psz = strchr( psz_dup, ':' );
@@ -2369,14 +2368,9 @@ void MRLSplit( vlc_object_t *p_input, char *psz_dup,
         psz_path = psz_dup;
     }
 
-    if( !psz_access ) *ppsz_access = "";
-    else *ppsz_access = psz_access;
-
-    if( !psz_demux ) *ppsz_demux = "";
-    else *ppsz_demux = psz_demux;
-
-    if( !psz_path ) *ppsz_path = "";
-    else *ppsz_path = psz_path;
+    *ppsz_access = psz_access;
+    *ppsz_demux = psz_demux;
+    *ppsz_path = psz_path;
 }
 
 /*****************************************************************************
index b88d5f3..ccd46b3 100644 (file)
@@ -154,7 +154,7 @@ mtime_t input_ClockGetTS( input_thread_t *, input_clock_t *, mtime_t );
 char **subtitles_Detect( input_thread_t *, char* path, char *fname );
 int subtitles_Filter( const char *);
 
-void MRLSplit( vlc_object_t *, char *, const char **, const char **, const char ** );
+void MRLSplit( vlc_object_t *, char *, const char **, const char **, char ** );
 
 static inline void input_ChangeState( input_thread_t *p_input, int state )
 {