From e2e63ad12b7f6b35e08fe1b692a5a49d9b220f32 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Wed, 5 Jan 2000 13:48:58 +0000 Subject: [PATCH] free some memory git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@7721 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftpd/ls.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/appl/ftp/ftpd/ls.c b/appl/ftp/ftpd/ls.c index 5636d288a..872b0f90f 100644 --- a/appl/ftp/ftpd/ls.c +++ b/appl/ftp/ftpd/ls.c @@ -50,6 +50,19 @@ struct fileinfo { char *link; }; +static void +free_fileinfo(struct fileinfo *f) +{ + free(f->user); + free(f->group); + free(f->size); + free(f->major); + free(f->minor); + free(f->date); + free(f->filename); + free(f->link); +} + #define LS_DIRS 1 #define LS_IGNORE_DOT 2 #define LS_SORT_MODE 12 @@ -362,7 +375,7 @@ lstat_file (const char *file, struct stat *sb) } static void -list_files(FILE *out, char **files, int n_files, int flags) +list_files(FILE *out, const char **files, int n_files, int flags) { struct fileinfo *fi; int i; @@ -468,6 +481,9 @@ list_files(FILE *out, char **files, int n_files, int flags) max_major, max_minor, max_date); + for(i = 0; i < n_files; i++) + free_fileinfo(&fi[i]); + free(fi); } } @@ -522,7 +538,7 @@ list_dir(FILE *out, const char *directory, int flags) ++n_files; } closedir(d); - list_files(out, files, n_files, flags | LS_DIRS); + list_files(out, (const char**)files, n_files, flags | LS_DIRS); } void