[PATCH] Be nicer about cleaning up allocated memory
[fio.git] / filesetup.c
index d6df4f9fccb7b699c7e5dcfe292bbd4b6d65d8ac..2e81a1d10c88320e4396d625e99be1e9d9a04a9f 100644 (file)
@@ -406,6 +406,8 @@ void close_files(struct thread_data *td)
                if (f->fd != -1) {
                        if (td->unlink && td->filetype == FIO_TYPE_FILE)
                                unlink(f->file_name);
+                       free(f->file_name);
+                       f->file_name = NULL;
                        close(f->fd);
                        f->fd = -1;
                }
@@ -414,4 +416,8 @@ void close_files(struct thread_data *td)
                        f->mmap = NULL;
                }
        }
+
+       free(td->files);
+       td->files = NULL;
+       td->nr_files = 0;
 }