1
mirror of https://code.videolan.org/videolan/vlc synced 2024-07-21 07:24:15 +02:00

Add vlclua_dir_list_free to free list created by vlclua_dir_list and use it.

This commit is contained in:
Rémi Duraffort 2008-08-01 20:00:54 +02:00
parent 07be8bb586
commit 588723d7c6
2 changed files with 12 additions and 2 deletions

View File

@ -143,6 +143,13 @@ int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list )
return VLC_SUCCESS;
}
void vlclua_dir_list_free( char **ppsz_dir_list )
{
char **ppsz_dir;
for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
free( *ppsz_dir );
}
/*****************************************************************************
* Will execute func on all scripts in luadirname, and stop if func returns
* success.
@ -192,7 +199,10 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
char *psz_filename;
if( asprintf( &psz_filename,
"%s" DIR_SEP "%s", *ppsz_dir, *ppsz_file ) < 0)
{
vlclua_dir_list_free( ppsz_dir_list );
return VLC_ENOMEM;
}
msg_Dbg( p_this, "Trying Lua playlist script %s", psz_filename );
i_ret = func( p_this, psz_filename, L, user_data );
@ -211,8 +221,7 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
free( *ppsz_file );
free( ppsz_filelist );
}
for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
free( *ppsz_dir );
vlclua_dir_list_free( ppsz_dir_list );
return i_ret;
}

View File

@ -106,6 +106,7 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this, const char * luadirname,
int (*func)(vlc_object_t *, const char *, lua_State *, void *),
lua_State * L, void * user_data );
int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list );
void vlclua_dir_list_free( char **ppsz_dir_list );
/*****************************************************************************
* Playlist and meta data internal utilities.