From b1b5e08232b69558bd4422e59528725424e50dda Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Sun, 25 Sep 2011 14:14:47 -0700 Subject: [PATCH] Fix and cleanup profile and preset dirs. --- src/framework/mlt_profile.c | 8 ++------ src/framework/mlt_properties.c | 6 ++++-- src/framework/mlt_repository.c | 4 +--- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/framework/mlt_profile.c b/src/framework/mlt_profile.c index ce93957e..9e3b7ce3 100644 --- a/src/framework/mlt_profile.c +++ b/src/framework/mlt_profile.c @@ -57,10 +57,8 @@ static mlt_profile mlt_profile_select( const char *name ) else if ( prefix == NULL ) { prefix = DATADIR; - filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + strlen( name ) + 2 ); + filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + strlen( name ) + 1 ); strcpy( filename, prefix ); - if ( filename[ strlen( filename ) - 1 ] != '/' ) - filename[ strlen( filename ) ] = '/'; strcat( filename, PROFILES_DIR ); } // Use environment variable instead @@ -357,10 +355,8 @@ mlt_properties mlt_profile_list( ) if ( prefix == NULL ) { prefix = mlt_environment( "MLT_DATA" ); - filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + 2 ); + filename = calloc( 1, strlen( prefix ) + strlen( PROFILES_DIR ) + 1 ); strcpy( filename, prefix ); - if ( filename[ strlen( filename ) - 1 ] != '/' ) - filename[ strlen( filename ) ] = '/'; strcat( filename, PROFILES_DIR ); prefix = filename; } diff --git a/src/framework/mlt_properties.c b/src/framework/mlt_properties.c index 39b1339f..c381e239 100644 --- a/src/framework/mlt_properties.c +++ b/src/framework/mlt_properties.c @@ -40,6 +40,8 @@ #include #include +#define PRESETS_DIR "/presets" + /** \brief private implementation of the property list */ typedef struct @@ -285,9 +287,9 @@ int mlt_properties_preset( mlt_properties self, const char *name ) } else { - data = malloc( strlen( mlt_environment( "MLT_DATA" ) ) + 9 ); + data = malloc( strlen( mlt_environment( "MLT_DATA" ) ) + strlen( PRESETS_DIR ) + 1 ); strcpy( data, mlt_environment( "MLT_DATA" ) ); - strcat( data, "/presets" ); + strcat( data, PRESETS_DIR ); } if ( data && type && service ) { diff --git a/src/framework/mlt_repository.c b/src/framework/mlt_repository.c index ffb65daf..acda89cc 100644 --- a/src/framework/mlt_repository.c +++ b/src/framework/mlt_repository.c @@ -495,10 +495,8 @@ mlt_properties mlt_repository_presets( ) } else { - path = malloc( strlen( mlt_environment( "MLT_DATA" ) ) + 9 ); + path = malloc( strlen( mlt_environment( "MLT_DATA" ) ) + strlen( PRESETS_DIR ) + 1 ); strcpy( path, mlt_environment( "MLT_DATA" ) ); - if ( path[ strlen( path ) - 1 ] != '/' ) - path[ strlen( path ) ] = '/'; strcat( path, PRESETS_DIR ); } list_presets( result, NULL, path ); -- 2.39.2