[vlc-devel] commit: Simplify executable name retrieval and fix a memory leak ( Rafaël Carré )
Remi Denis-Courmont
rdenis at simphalempin.com
Mon May 5 12:51:44 CEST 2008
On Mon, 5 May 2008 10:40:38 +0200 (CEST), git at videolan.org (git version
control) wrote:
> --- a/src/libvlc-common.c
> +++ b/src/libvlc-common.c
> @@ -250,18 +250,21 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc,
int
> i_argc,
> /* Get the executable name (similar to the basename command) */
> if( i_argc > 0 )
> {
> - const char *exe = ppsz_argv[0];
> - const char *tmp = exe;
> - while( *exe )
> + const char *psz_exe = ppsz_argv[0] + strlen( ppsz_argv[0] );
> + for( ; psz_exe > ppsz_argv[0] ; psz_exe-- )
> {
> - if( *exe++ == '/' )
> - tmp = exe;
> + if( *psz_exe == '/' )
> + {
> + psz_exe++;
> + break;
> + }
> + }
> +
strrchr() ?
--
Rémi Denis-Courmont
http://www.remlab.net
More information about the vlc-devel
mailing list