Add a really simple allocator, backed with mmap'ed memory
[fio.git] / filesetup.c
index c0403d2a801e863df927ed87a2a935161c7cb394..b37de5b726b3203d27eed4c99281948d67a67ed3 100644 (file)
@@ -585,12 +585,14 @@ int add_file(struct thread_data *td, const char *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;
 
+       td->files = realloc(td->files, (cur_files + 1) * sizeof(f));
+
+       td->files[cur_files] = f;
+
        /*
         * init function, io engine may not be loaded yet
         */
@@ -643,6 +645,14 @@ int put_file(struct thread_data *td, struct fio_file *f)
        return ret;
 }
 
+void lock_file(struct thread_data *td, struct fio_file *f)
+{
+}
+
+void unlock_file(struct fio_file *f)
+{
+}
+
 static int recurse_dir(struct thread_data *td, const char *dirname)
 {
        struct dirent *dir;
@@ -709,13 +719,20 @@ void dup_files(struct thread_data *td, struct thread_data *org)
        if (!org->files)
                return;
 
-       bytes = org->files_index * sizeof(*f);
+       bytes = org->files_index * sizeof(f);
        td->files = malloc(bytes);
        memcpy(td->files, org->files, bytes);
 
        for_each_file(td, f, i) {
+               struct fio_file *__f;
+
+               __f = malloc(sizeof(*__f));
+               memset(f, 0, sizeof(*__f));
+
                if (f->file_name)
-                       f->file_name = strdup(f->file_name);
+                       __f->file_name = strdup(f->file_name);
+
+               td->files[i] = __f;
        }
 }