Skip to content

Commit

Permalink
Added function to free the list that was created with fl_filename_list.
Browse files Browse the repository at this point in the history
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8065 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
  • Loading branch information
Matthias Melcher committed Dec 19, 2010
1 parent 22953cc commit 740d7e2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions FL/filename.H
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions src/filename_list.cxx
Expand Up @@ -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$".
//

0 comments on commit 740d7e2

Please sign in to comment.