Memory leak fixes

Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/options.c b/options.c
index 48bb2a4..4207537 100644
--- a/options.c
+++ b/options.c
@@ -2347,7 +2347,10 @@
 	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;
@@ -2359,32 +2362,13 @@
 			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;
@@ -2465,3 +2449,8 @@
 		o->posval[i].help = NULL;
 	}
 }
+
+void fio_options_free(struct thread_data *td)
+{
+	options_free(options, td);
+}