From 96d994d3476a7fe023788d1ad5cbedb37fedfce6 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 30 Jun 2008 17:32:37 +0100 Subject: [PATCH] Replace copy_string with strdup --- src/settings.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/settings.c b/src/settings.c index bd28db9..337eafd 100644 --- a/src/settings.c +++ b/src/settings.c @@ -131,17 +131,10 @@ void add_bool_option(const char *name, bool bval) add_option(name, optBool, u); } -static char *copy_string(const char *s) -{ - char *copy = malloc(strlen(s)+1); - strcpy(copy, s); - return copy; -} - void add_string_option(const char *name, const char *sval) { option_value_t u; - u.sval = copy_string(sval); + u.sval = strdup(sval); add_option(name, optString, u); } @@ -164,5 +157,5 @@ void set_string_option(const char *name, const char *sval) option_t *opt = get_option(name); assert_string(opt); free(opt->u.sval); - opt->u.sval = copy_string(sval); + opt->u.sval = strdup(sval); } -- 2.39.2