summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FL/filename.H1
-rw-r--r--src/filename_list.cxx23
2 files changed, 24 insertions, 0 deletions
diff --git a/FL/filename.H b/FL/filename.H
index 1209a8771..4d1ed9ecc 100644
--- a/FL/filename.H
+++ b/FL/filename.H
@@ -130,6 +130,7 @@ FL_EXPORT int fl_numericsort(struct dirent **, struct dirent **);
FL_EXPORT int fl_filename_list(const char *d, struct dirent ***l,
Fl_File_Sort_F *s = fl_numericsort);
+FL_EXPORT void fl_filename_free_list(struct dirent ***l, int n);
/*
* Generic function to open a Uniform Resource Identifier (URI) using a
diff --git a/src/filename_list.cxx b/src/filename_list.cxx
index e60736286..3de968ea2 100644
--- a/src/filename_list.cxx
+++ b/src/filename_list.cxx
@@ -131,6 +131,29 @@ int fl_filename_list(const char *d, dirent ***list,
return n;
}
+/**
+ \brief Free the list of filenames that is generated by fl_filename_list().
+
+ Free everything that was allocated by a previous call to fl_filename_list().
+ Use the return values as parameters for this function.
+
+ \param[in,out] list table containing the resulting directory listing
+ \param[in] n number of entries in the list
+ */
+void fl_filename_free_list(struct dirent ***list, int n)
+{
+ if (n<0) return;
+
+ int i;
+ for (i = 0; i < n; i ++) {
+ if ((*list)[i])
+ free((*list)[i]);
+ }
+ free(*list);
+ *list = 0;
+}
+
+
//
// End of "$Id$".
//