[vlc-devel] commit: Add vlclua_dir_list_free to free list created by vlclua_dir_list and use it . ( Rémi Duraffort )

git version control git at videolan.org
Fri Aug 1 20:03:54 CEST 2008


vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Fri Aug  1 20:00:54 2008 +0200| [588723d7c65ccdb0fa5cc39b3cae132176637300] | committer: Rémi Duraffort 

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

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=588723d7c65ccdb0fa5cc39b3cae132176637300
---

 modules/misc/lua/vlc.c |   13 +++++++++++--
 modules/misc/lua/vlc.h |    1 +
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/modules/misc/lua/vlc.c b/modules/misc/lua/vlc.c
index ad5c0b5..36fee88 100644
--- a/modules/misc/lua/vlc.c
+++ b/modules/misc/lua/vlc.c
@@ -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;
 }
diff --git a/modules/misc/lua/vlc.h b/modules/misc/lua/vlc.h
index b47e850..c4cb9a4 100644
--- a/modules/misc/lua/vlc.h
+++ b/modules/misc/lua/vlc.h
@@ -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.




More information about the vlc-devel mailing list