Make file structures dynamically allocated
Current td->files is an array of files, make it an array of pointers
instead and allocate individual file structures on the fly. This is
a preparation patch for file sharing.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index c0403d2..483226a 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -585,12 +585,14 @@
dprint(FD_FILE, "add file %s\n", fname);
- td->files = realloc(td->files, (cur_files + 1) * sizeof(*f));
-
- f = &td->files[cur_files];
+ f = malloc(sizeof(*f));
memset(f, 0, sizeof(*f));
f->fd = -1;
+ td->files = realloc(td->files, (cur_files + 1) * sizeof(f));
+
+ td->files[cur_files] = f;
+
/*
* init function, io engine may not be loaded yet
*/