diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-03 14:27:40 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2015-01-03 14:41:36 +0300 |
commit | b137f06d7ecc7beae3b9fbeba0a71b324198c7e2 (patch) | |
tree | efef56b487ec1907a145bc0b130072fcced4b856 /source/blender/blenlib | |
parent | 780bb88a7a5b30eaf8a62b999a30ac7bb4153ebf (diff) |
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()`...).
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/BLI_fileops.h | 6 | ||||
-rw-r--r-- | source/blender/blenlib/intern/fileops.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 11 |
3 files changed, 13 insertions, 8 deletions
diff --git a/source/blender/blenlib/BLI_fileops.h b/source/blender/blenlib/BLI_fileops.h index 8e056651f7f..7b67a4fd7f4 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 99b9f7931d8..62e1b6e4cbf 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 78057b1655f..3e680cc8c5a 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); |