Commit: b137f06d7ecc7beae3b9fbeba0a71b324198c7e2
Author: Bastien Montagne
Date:   Sat Jan 3 12:27:40 2015 +0100
Branches: master
https://developer.blender.org/rBb137f06d7ecc7beae3b9fbeba0a71b324198c7e2

Cleanup: rename 'filelist' BLI funcs to consistent naming.

Also, add an optional callback to `BLI_filelist_free()` to allow freein
void poin if needed (consistency with `BLI_filelist_duplicate()`...).

===================================================================

M       source/blender/blenlib/BLI_fileops.h
M       source/blender/blenlib/intern/fileops.c
M       source/blender/blenlib/intern/storage.c
M       source/blender/editors/interface/interface_icons.c
M       source/blender/editors/interface/interface_templates.c
M       source/blender/editors/space_file/filelist.c

===================================================================

diff --git a/source/blender/blenlib/BLI_fileops.h 
b/source/blender/blenlib/BLI_fileops.h
index 8e05665..7b67a4f 100644
--- a/source/blender/blenlib/BLI_fileops.h
+++ b/source/blender/blenlib/BLI_fileops.h
@@ -88,11 +88,13 @@ void   BLI_dir_create_recursive(const char *dir);
 double BLI_dir_free_space(const char *dir);
 char  *BLI_current_working_dir(char *dir, const size_t maxlen);
 
-unsigned int BLI_dir_contents(const char *dir, struct direntry **filelist);
+/* Filelist */
+
+unsigned int BLI_filelist_dir_contents(const char *dir, struct direntry 
**filelist);
 void BLI_filelist_duplicate(
         struct direntry **dest_filelist, struct direntry *src_filelist, 
unsigned int nrentries,
         void *(*dup_poin)(void *));
-void BLI_free_filelist(struct direntry *filelist, unsigned int nrentries);
+void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries, void 
(free_poin)(void *));
 
 /* Files */
 
diff --git a/source/blender/blenlib/intern/fileops.c 
b/source/blender/blenlib/intern/fileops.c
index 99b9f79..62e1b6e 100644
--- a/source/blender/blenlib/intern/fileops.c
+++ b/source/blender/blenlib/intern/fileops.c
@@ -311,7 +311,7 @@ static bool delete_recursive(const char *dir)
        bool err = false;
        unsigned int nbr, i;
 
-       i = nbr = BLI_dir_contents(dir, &filelist);
+       i = nbr = BLI_filelist_dir_contents(dir, &filelist);
        fl = filelist;
        while (i--) {
                char file[8];
@@ -336,7 +336,7 @@ static bool delete_recursive(const char *dir)
                err = true;
        }
 
-       BLI_free_filelist(filelist, nbr);
+       BLI_filelist_free(filelist, nbr, NULL);
 
        return err;
 }
diff --git a/source/blender/blenlib/intern/storage.c 
b/source/blender/blenlib/intern/storage.c
index 78057b1..3e680cc 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -385,9 +385,11 @@ static void bli_adddirstrings(struct BuildDirCtx *dir_ctx)
 
 /**
  * Scans the contents of the directory named *dirname, and allocates and fills 
in an
- * array of entries describing them in *filelist. The length of the array is 
the function result.
+ * array of entries describing them in *filelist.
+ *
+ * \return The length of filelist array.
  */
-unsigned int BLI_dir_contents(const char *dirname,  struct direntry **filelist)
+unsigned int BLI_filelist_dir_contents(const char *dirname,  struct direntry 
**filelist)
 {
        struct BuildDirCtx dir_ctx;
 
@@ -443,7 +445,7 @@ void BLI_filelist_duplicate(
 /**
  * frees storage for an array of direntries, including the array itself.
  */
-void BLI_free_filelist(struct direntry *filelist, unsigned int nrentries)
+void BLI_filelist_free(struct direntry *filelist, unsigned int nrentries, void 
(*free_poin)(void *))
 {
        unsigned int i;
        for (i = 0; i < nrentries; ++i) {
@@ -455,7 +457,8 @@ void BLI_free_filelist(struct direntry *filelist, unsigned 
int nrentries)
                        MEM_freeN(entry->relname);
                if (entry->path)
                        MEM_freeN(entry->path);
-               /* entry->poin assumed not to point to anything needing freeing 
here */
+               if (entry->poin && free_poin)
+                       free_poin(entry->poin);
        }
 
        free(filelist);
diff --git a/source/blender/editors/interface/interface_icons.c 
b/source/blender/editors/interface/interface_icons.c
index a54ced5..cb5a26b 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -708,7 +708,7 @@ static void init_iconfile_list(struct ListBase *list)
        if (icondir == NULL)
                return;
        
-       totfile = BLI_dir_contents(icondir, &dir);
+       totfile = BLI_filelist_dir_contents(icondir, &dir);
 
        for (i = 0; i < totfile; i++) {
                if ((dir[i].type & S_IFREG)) {
@@ -756,7 +756,7 @@ static void init_iconfile_list(struct ListBase *list)
                }
        }
 
-       BLI_free_filelist(dir, totfile);
+       BLI_filelist_free(dir, totfile, NULL);
        dir = NULL;
 }
 
diff --git a/source/blender/editors/interface/interface_templates.c 
b/source/blender/editors/interface/interface_templates.c
index e3fa591..407843d 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -2672,7 +2672,7 @@ static void uilist_filter_items_default(struct uiList 
*ui_list, struct bContext
                        names = MEM_callocN(sizeof(StringCmp) * len, 
"StringCmp");
                }
                if (filter_raw[0]) {
-                       size_t idx = 0, slen = strlen(filter_raw);
+                       size_t slen = strlen(filter_raw);
 
                        dyn_data->items_filter_flags = MEM_callocN(sizeof(int) 
* len, "items_filter_flags");
                        dyn_data->items_shown = 0;
diff --git a/source/blender/editors/space_file/filelist.c 
b/source/blender/editors/space_file/filelist.c
index f8248d9..abfa1ed 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -736,7 +736,7 @@ void filelist_free(struct FileList *filelist)
        filelist->need_sorting = false;
        filelist->sort = FILE_SORT_NONE;
 
-       BLI_free_filelist(filelist->filelist, filelist->numfiles);
+       BLI_filelist_free(filelist->filelist, filelist->numfiles, NULL);
        filelist->numfiles = 0;
        filelist->filelist = NULL;
 }
@@ -953,7 +953,7 @@ static void filelist_read_dir(struct FileList *filelist)
        filelist->filelist = NULL;
 
        BLI_cleanup_dir(G.main->name, filelist->dir);
-       filelist->numfiles = BLI_dir_contents(filelist->dir, 
&(filelist->filelist));
+       filelist->numfiles = BLI_filelist_dir_contents(filelist->dir, 
&(filelist->filelist));
 
        filelist_setfiletypes(filelist);
 }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to