summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-11-27 19:12:42 -0800
committerJeremy Allison <jra@samba.org>2007-11-27 19:12:42 -0800
commitb11e6f21589a00c1803985f202be9cd360944d43 (patch)
treed166a1ee98227dcd03768be46bcf21a86b7722ca /source3
parent0bc4ff7b287e2cd6f7b225861d6c3fda9347adfc (diff)
downloadsamba-b11e6f21589a00c1803985f202be9cd360944d43.tar.gz
samba-b11e6f21589a00c1803985f202be9cd360944d43.tar.bz2
samba-b11e6f21589a00c1803985f202be9cd360944d43.zip
Save one extra strdup per lp_string. Use talloc_sub_basic()
directly. Jeremy. (This used to be commit f1e401ef5c89ecf12921b7adb228da438521a693)
Diffstat (limited to 'source3')
-rw-r--r--source3/param/loadparm.c26
1 files 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;
}
/*