Since we have two spots, provide a helper to do the freeing.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
extern bool fio_files_done(struct thread_data *);
extern bool exists_and_not_regfile(const char *);
extern int fio_set_directio(struct thread_data *, struct fio_file *);
+extern void fio_file_free(struct fio_file *);
#endif
}
}
+void fio_file_free(struct fio_file *f)
+{
+ if (fio_file_axmap(f))
+ axmap_free(f->io_axmap);
+ if (!fio_file_smalloc(f)) {
+ free(f->file_name);
+ free(f);
+ } else {
+ sfree(f->file_name);
+ sfree(f);
+ }
+}
+
void close_and_free_files(struct thread_data *td)
{
struct fio_file *f;
}
zbd_close_file(f);
-
- if (!fio_file_smalloc(f))
- free(f->file_name);
- else
- sfree(f->file_name);
- f->file_name = NULL;
- if (fio_file_axmap(f)) {
- axmap_free(f->io_axmap);
- f->io_axmap = NULL;
- }
- if (!fio_file_smalloc(f))
- free(f);
- else
- sfree(f);
+ fio_file_free(f);
}
td->o.filename = NULL;
if (file_alloced) {
if (td_new->files) {
struct fio_file *f;
- for_each_file(td_new, f, i) {
- bool use_smalloc = fio_file_smalloc(f);
- if (f->file_name) {
- if (use_smalloc)
- sfree(f->file_name);
- else
- free(f->file_name);
- }
- if (use_smalloc)
- sfree(f);
- else
- free(f);
- }
+ for_each_file(td_new, f, i)
+ fio_file_free(f);
free(td_new->files);
td_new->files = NULL;
}