Make file structures dynamically allocated
[fio.git] / filesetup.c
index c0403d2a801e863df927ed87a2a935161c7cb394..483226ae56e5d488d4601a14c1ba29b93f91d360 100644 (file)
@@ -585,12 +585,14 @@ int add_file(struct thread_data *td, const char *fname)
 
        dprint(FD_FILE, "add file %s\n", fname);
 
 
        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;
 
        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
         */
        /*
         * init function, io engine may not be loaded yet
         */