]> git.sesse.net Git - vlc/commitdiff
Simplification (and use only the needed memory).
authorRémi Duraffort <ivoire@videolan.org>
Tue, 26 May 2009 17:54:04 +0000 (19:54 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Tue, 26 May 2009 21:03:53 +0000 (23:03 +0200)
modules/demux/playlist/playlist.c

index dd747415a59a3d05bd2ec03c997fadce3b497af6..ca238ababa9b695c4743928d72c94b03e097fbcb 100644 (file)
@@ -172,19 +172,22 @@ vlc_module_end ()
  */
 char *FindPrefix( demux_t *p_demux )
 {
-    char *psz_name;
-    char *psz_path = strdup( p_demux->psz_path );
+    char *psz_file;
+    char *psz_prefix;
+    const char *psz_path = p_demux->psz_path;
 
 #ifndef WIN32
-    psz_name = strrchr( psz_path, '/' );
+    psz_file = strrchr( psz_path, '/' );
 #else
-    psz_name = strrchr( psz_path, '\\' );
-    if( !psz_name ) psz_name = strrchr( psz_path, '/' );
+    psz_file = strrchr( psz_path, '\\' );
+    if( !psz_file ) psz_name = strrchr( psz_path, '/' );
 #endif
-    if( psz_name ) psz_name[1] = '\0';
-    else *psz_path = '\0';
+    if( psz_file )
+        psz_prefix = strndup( psz_path, psz_file - psz_path + 1 );
+    else
+        psz_prefix = strdup( "" );
 
-    return psz_path;
+    return psz_prefix;
 }
 
 /**