From b11e6f21589a00c1803985f202be9cd360944d43 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 27 Nov 2007 19:12:42 -0800 Subject: Save one extra strdup per lp_string. Use talloc_sub_basic() directly. Jeremy. (This used to be commit f1e401ef5c89ecf12921b7adb228da438521a693) --- source3/param/loadparm.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c index 80eac747c6..16c6c59c7d 100644 --- a/source3/param/loadparm.c +++ b/source3/param/loadparm.c @@ -1729,7 +1729,8 @@ static void init_globals(bool first_time_only) static char *lp_string(const char *s) { - char *ret, *tmpstr; + char *ret; + TALLOC_CTX *ctx = talloc_tos(); /* The follow debug is useful for tracking down memory problems especially if you have an inner loop that is calling a lp_*() @@ -1740,19 +1741,20 @@ static char *lp_string(const char *s) DEBUG(10, ("lp_string(%s)\n", s)); #endif - tmpstr = alloc_sub_basic(get_current_username(), - current_user_info.domain, s); - if (trim_char(tmpstr, '\"', '\"')) { - if (strchr(tmpstr,'\"') != NULL) { - SAFE_FREE(tmpstr); - tmpstr = alloc_sub_basic(get_current_username(), - current_user_info.domain, s); + ret = talloc_sub_basic(ctx, + get_current_username(), + current_user_info.domain, + s); + if (trim_char(ret, '\"', '\"')) { + if (strchr(ret,'\"') != NULL) { + TALLOC_FREE(ret); + ret = talloc_sub_basic(ctx, + get_current_username(), + current_user_info.domain, + s); } } - ret = talloc_strdup(talloc_tos(), tmpstr); - SAFE_FREE(tmpstr); - - return (ret); + return ret; } /* -- cgit