From 7e501d16ee2d458990cf27ac7d332572c91df856 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Thu, 7 Jun 2007 17:22:05 +0000 Subject: [PATCH] - Avoid a bunch of dummy string copy - Use strdup() instead of asprintf("%s") - Fix format string (CDDB now owns your CD player) --- modules/access/cdda.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/modules/access/cdda.c b/modules/access/cdda.c index 4181b416a0..38c1eb59a5 100644 --- a/modules/access/cdda.c +++ b/modules/access/cdda.c @@ -414,12 +414,10 @@ static int GetTracks( access_t *p_access, } p_item_in_category = playlist_ItemToNode( p_playlist, p_parent, VLC_FALSE ); - psz_name = strdup( "Audio CD" ); vlc_mutex_lock( &p_playlist->object_lock ); - playlist_ItemSetName( p_parent, psz_name ); + playlist_ItemSetName( p_parent, "Audio CD" ); vlc_mutex_unlock( &p_playlist->object_lock ); var_SetInteger( p_playlist, "item-change", p_parent->p_input->i_id ); - free( psz_name ); #ifdef HAVE_LIBCDDB GetCDDBInfo( p_access, i_titles, p_sys->p_sectors ); @@ -427,13 +425,12 @@ static int GetTracks( access_t *p_access, { if( cddb_disc_get_title( p_sys->p_disc ) ) { - asprintf( &psz_name, "%s", cddb_disc_get_title( p_sys->p_disc ) ); + const char *psz_name = cddb_disc_get_title( p_sys->p_disc ); vlc_mutex_lock( &p_playlist->object_lock ); playlist_ItemSetName( p_parent, psz_name ); vlc_mutex_unlock( &p_playlist->object_lock ); var_SetInteger( p_playlist, "item-change", p_parent->p_input->i_id ); - free( psz_name ); } } #endif @@ -484,17 +481,16 @@ static int GetTracks( access_t *p_access, { input_ItemAddInfo( p_input_item, _(VLC_META_INFO_CAT), _(VLC_META_TITLE), - cddb_track_get_title( t ) ); + "%s", cddb_track_get_title( t ) ); if( p_input_item->psz_name ) free( p_input_item->psz_name ); - asprintf( &p_input_item->psz_name, "%s", - cddb_track_get_title( t ) ); + p_input_item->psz_name = strdup( cddb_track_get_title( t ) ); } psz_result = cddb_track_get_artist( t ); if( psz_result ) { input_ItemAddInfo( p_input_item, _(VLC_META_INFO_CAT), - _(VLC_META_ARTIST), psz_result ); + _(VLC_META_ARTIST), "%s", psz_result ); } } } -- 2.39.2