if (td->o.write_iolog_file)
write_iolog_close(td);
- options_mem_free(td);
td_set_runstate(td, TD_EXITED);
return (void *) (unsigned long) td->error;
}
int exec_run(void)
{
+ struct thread_data *td;
+ int i;
+
if (nr_clients)
return fio_handle_clients();
- if (exec_profile && load_profile(exec_profile))
- return 1;
-
+ if (exec_profile) {
+ if (load_profile(exec_profile))
+ return 1;
+ free(exec_profile);
+ exec_profile = NULL;
+ }
if (!thread_number)
return 0;
}
}
+ for_each_td(td, i)
+ fio_options_free(td);
+
cgroup_kill(cgroup_list);
sfree(cgroup_list);
sfree(cgroup_mnt);
if (td->error)
log_info("fio: %s\n", td->verror);
+ fio_options_free(td);
+
memset(&threads[td->thread_number - 1], 0, sizeof(*td));
thread_number--;
}
if (dump_cmdline)
log_info("\n");
+ i = 0;
+ while (i < nr_job_sections) {
+ free(job_sections[i]);
+ i++;
+ }
+
for (i = 0; i < num_opts; i++)
free(opts[i]);
}
free(ini_file);
- options_mem_free(&def_thread);
+ fio_options_free(&def_thread);
if (!thread_number) {
if (dump_cmdline)
return show_cmd_help(options, opt);
}
-static void __options_mem(struct thread_data *td, int alloc)
+/*
+ * dupe FIO_OPT_STR_STORE options
+ */
+void options_mem_dupe(struct thread_data *td)
{
struct thread_options *o = &td->o;
struct fio_option *opt;
continue;
ptr = (void *) o + opt->off1;
- if (*ptr) {
- if (alloc)
- *ptr = strdup(*ptr);
- else {
- free(*ptr);
- *ptr = NULL;
- }
- }
+ if (!*ptr)
+ ptr = td_var(o, opt->off1);
+ if (*ptr)
+ *ptr = strdup(*ptr);
}
}
-/*
- * 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 fio_unused *td)
-{
-#if 0
- __options_mem(td, 0);
-#endif
-}
-
unsigned int fio_get_kb_base(void *data)
{
struct thread_data *td = data;
o->posval[i].help = NULL;
}
}
+
+void fio_options_free(struct thread_data *td)
+{
+ options_free(options, td);
+}
void add_opt_posval(const char *, const char *, const char *);
void del_opt_posval(const char *, const char *);
+struct thread_data;
+void fio_options_free(struct thread_data *);
static inline int o_match(struct fio_option *o, const char *opt)
{
for (o = &options[0]; o->name; o++)
option_init(o);
}
+
+void options_free(struct fio_option *options, void *data)
+{
+ struct fio_option *o;
+ char **ptr;
+
+ dprint(FD_PARSE, "free options\n");
+
+ for (o = &options[0]; o->name; o++) {
+ if (o->type != FIO_OPT_STR_STORE)
+ continue;
+
+ ptr = td_var(data, o->off1);
+ if (*ptr) {
+ free(*ptr);
+ *ptr = NULL;
+ }
+ }
+}
extern void fill_default_options(void *, struct fio_option *);
extern void option_init(struct fio_option *);
extern void options_init(struct fio_option *);
+extern void options_free(struct fio_option *, void *);
extern void strip_blank_front(char **);
extern void strip_blank_end(char *);