[vlc-devel] commit: Simplification (and use only the needed memory). ( Rémi Duraffort )

git version control git at videolan.org
Tue May 26 23:22:35 CEST 2009


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue May 26 19:54:04 2009 +0200| [3a6da657f15627671b387ece349295d45aba0475] | committer: Rémi Duraffort 

Simplification (and use only the needed memory).

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

 modules/demux/playlist/playlist.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/modules/demux/playlist/playlist.c b/modules/demux/playlist/playlist.c
index dd74741..ca238ab 100644
--- a/modules/demux/playlist/playlist.c
+++ b/modules/demux/playlist/playlist.c
@@ -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;
 }
 
 /**




More information about the vlc-devel mailing list