Makes ownership clear, though the freeing is a bit anal.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
close_files(td);
close_ioengine(td);
cleanup_io_u(td);
+ options_mem_free(td);
td_set_runstate(td, TD_EXITED);
return (void *) (unsigned long) td->error;
err_sem:
extern void fio_fill_default_options(struct thread_data *);
extern int fio_show_option_help(const char *);
extern void fio_options_dup_and_init(struct option *);
+extern void options_mem_dupe(struct thread_data *);
+extern void options_mem_free(struct thread_data *);
#define FIO_GETOPT_JOB 0x89988998
#define FIO_NR_OPTIONS 128
*td = *parent;
dup_files(td, parent);
+ options_mem_dupe(td);
td->thread_number = thread_number;
return td;
}
free(ini_file);
+ options_mem_free(&def_thread);
if (!thread_number) {
log_err("No jobs defined(s)\n");
{
return show_cmd_help(options, opt);
}
+
+static void __options_mem(struct thread_data *td, int alloc)
+{
+ struct thread_options *o = &td->o;
+ struct fio_option *opt;
+ char **ptr;
+ int i;
+
+ for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
+ if (opt->type != FIO_OPT_STR_STORE)
+ continue;
+
+ ptr = (void *) o + opt->off1;
+ if (*ptr) {
+ if (alloc)
+ *ptr = strdup(*ptr);
+ else {
+ free(*ptr);
+ *ptr = NULL;
+ }
+ }
+ }
+}
+
+/*
+ * dupe FIO_OPT_STR_STORE options
+ */
+void options_mem_dupe(struct thread_data *td)
+{
+ __options_mem(td, 1);
+}
+
+void options_mem_free(struct thread_data *td)
+{
+ __options_mem(td, 0);
+}