[vlc-devel] commit: Rewrite logic in VLC_Init() to use asprintf. (Jean-Paul Saman )
git version control
git at videolan.org
Mon Oct 27 16:23:27 CET 2008
vlc | branch: 0.8.6-bugfix | Jean-Paul Saman <jpsaman at videolan.org> | Tue Oct 21 10:29:53 2008 +0200| [15814b64e5878196de6ef6325dc1d8d219876362] | committer: Jean-Paul Saman
Rewrite logic in VLC_Init() to use asprintf.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=15814b64e5878196de6ef6325dc1d8d219876362
---
src/libvlc.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/src/libvlc.c b/src/libvlc.c
index 76777b9..871e00c 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -396,16 +396,17 @@ int VLC_Init( int i_object, int i_argc, char *ppsz_argv[] )
if( p_vlc->psz_userdir == NULL )
p_vlc->psz_userdir = strdup(p_vlc->psz_homedir);
p_vlc->psz_configfile = config_GetPsz( p_vlc, "config" );
- if( p_vlc->psz_configfile != NULL && p_vlc->psz_configfile[0] == '~'
- && p_vlc->psz_configfile[1] == '/' )
+ if( (p_vlc->psz_configfile != NULL) && (p_vlc->psz_configfile[0] == '~')
+ && (p_vlc->psz_configfile[1] == '/') )
{
- char *psz = malloc( strlen(p_vlc->psz_userdir)
- + strlen(p_vlc->psz_configfile) );
+ int i_ret;
+ char *psz = NULL;
+
/* This is incomplete : we should also support the ~cmassiot/ syntax. */
- sprintf( psz, "%s/%s", p_vlc->psz_userdir,
- p_vlc->psz_configfile + 2 );
+ i_ret = asprintf( &psz, "%s/%s", p_vlc->psz_userdir,
+ p_vlc->psz_configfile );
free( p_vlc->psz_configfile );
- p_vlc->psz_configfile = psz;
+ p_vlc->psz_configfile = (i_ret > 0) ? psz : NULL;
}
/* Check for plugins cache options */
@@ -1042,7 +1043,7 @@ int VLC_Destroy( int i_object )
var_Create( p_libvlc, "libvlc", VLC_VAR_MUTEX );
var_Get( p_libvlc, "libvlc", &lockval );
vlc_mutex_lock( lockval.p_address );
- vlc_bool_t b_destroy = --i_libvlc == 0;
+ vlc_bool_t b_destroy = (--i_libvlc == 0);
vlc_mutex_unlock( lockval.p_address );
if( b_destroy )
More information about the vlc-devel
mailing list