]> git.sesse.net Git - vlc/commitdiff
Don't use #ifdef + alloca() when we have something simpler
authorRémi Denis-Courmont <rem@videolan.org>
Sat, 29 Apr 2006 13:32:36 +0000 (13:32 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sat, 29 Apr 2006 13:32:36 +0000 (13:32 +0000)
modules/demux/mp4/mp4.c

index fb06728e6a3890a1e46be272b12fb1465a48458f..884aad8bd3db88b67371a310c3c32884c98e9494 100644 (file)
@@ -408,24 +408,17 @@ static int Open( vlc_object_t * p_this )
                         /* msg dbg relative ? */
                         int i_path_size = strlen( p_demux->psz_access ) + 3 +
                                          strlen( p_demux->psz_path ) + strlen( psz_ref ) + 1;
-#ifdef HAVE_ALLOCA
-                        char *psz_absolute = alloca( i_path_size );
-#else
-                        char *psz_absolute = (char *)malloc( i_path_size );
-#endif
+                        char psz_absolute[i_path_size];
                         char *end = strrchr( p_demux->psz_path, '/' );
 
                         if( end )
                         {
-                            int i_len = end + 1 - p_demux->psz_path;
-
-                            strcpy( psz_absolute, p_demux->psz_access );
-                            strcat( psz_absolute, "://" );
-                            strncat( psz_absolute, p_demux->psz_path, i_len);
+                            snprintf( psz_absolute, i_path_size, "%s://%s",
+                                      p_demux->psz_access, p_demux->psz_path );
                         }
                         else
                         {
-                            strcpy( psz_absolute, "" );
+                            *psz_absolute = '\0';
                         }
                         strcat( psz_absolute, psz_ref );
                         msg_Dbg( p_demux, "adding ref = `%s'", psz_absolute );
@@ -445,9 +438,6 @@ static int Open( vlc_object_t * p_this )
                                 b_play = VLC_TRUE;
                             }
                         }
-#ifndef HAVE_ALLOCA
-                        free( psz_absolute );
-#endif
                     }
                 }
                 else