From 2dd7c890792cf12049ec13b88aa4e9de23035f9d Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Thu, 27 Feb 2014 12:14:57 +1300 Subject: [PATCH] param: remove string_init and inline it into string_set In making this change, the special case has been removed for empty strings. The use of empty strings causes various issues with trying to mix s4 and s3 code. Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett Reviewed-on: https://gerrit.samba.org/156 Reviewed-by: Kamen Mazdrashki Reviewed-by: Jeremy Allison --- source3/param/loadparm.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index a47d5ce5457..fbfdb06d726 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -291,31 +291,6 @@ static void free_param_opts(struct parmlist_entry **popts); static const char null_string[] = ""; /** - Set a string value, allocing the space for the string -**/ - -static bool string_init(TALLOC_CTX *mem_ctx, char **dest,const char *src) -{ - size_t l; - - if (!src) - src = ""; - - l = strlen(src); - - if (l == 0) { - *dest = discard_const_p(char, null_string); - } else { - (*dest) = talloc_strdup(mem_ctx, src); - if ((*dest) == NULL) { - DEBUG(0,("Out of memory in string_init\n")); - return false; - } - } - return(true); -} - -/** Free a string value. **/ @@ -336,7 +311,18 @@ static void string_free(char **s) static bool string_set(TALLOC_CTX *mem_ctx, char **dest,const char *src) { string_free(dest); - return(string_init(mem_ctx, dest, src)); + + if (!src) { + src = ""; + } + + (*dest) = talloc_strdup(mem_ctx, src); + if ((*dest) == NULL) { + DEBUG(0,("Out of memory in string_init\n")); + return false; + } + + return true; } /*************************************************************************** -- 2.11.4.GIT