[PATCH] Cleanup allocation frees on exit
authorJens Axboe <axboe@suse.de>
Tue, 6 Jun 2006 08:06:42 +0000 (10:06 +0200)
committerJens Axboe <axboe@suse.de>
Tue, 6 Jun 2006 08:06:42 +0000 (10:06 +0200)
fio.c

diff --git a/fio.c b/fio.c
index bd938979f61caa3f59152d50c4eee03b24b84c53..84c7d3e710607a832d15b1ea711770663a036b46 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1282,6 +1282,22 @@ static int init_io_u(struct thread_data *td)
        return 0;
 }
 
+static void cleanup_allocs(struct thread_data *td)
+{
+       if (td->directory)
+               free(td->directory);
+       if (td->iolog_file)
+               free(td->iolog_file);
+       if (td->exec_prerun)
+               free(td->exec_prerun);
+       if (td->exec_postrun)
+               free(td->exec_postrun);
+       if (td->ioscheduler)
+               free(td->ioscheduler);
+       if (td->sysfs_root)
+               free(td->sysfs_root);
+}
+
 static int create_file(struct thread_data *td, unsigned long long size,
                       int extend)
 {
@@ -1990,18 +2006,7 @@ err:
        }
        if (td->mmap)
                munmap(td->mmap, td->file_size);
-       if (td->directory)
-               free(td->directory);
-       if (td->iolog_file)
-               free(td->iolog_file);
-       if (td->exec_prerun)
-               free(td->exec_prerun);
-       if (td->exec_postrun)
-               free(td->exec_postrun);
-       if (td->ioscheduler)
-               free(td->ioscheduler);
-       if (td->sysfs_root)
-               free(td->sysfs_root);
+       cleanup_allocs(td);
        cleanup_io(td);
        cleanup_io_u(td);
        td_set_runstate(td, TD_EXITED);