Commit 5cf11931 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Use REPLACE macro to manipulate malloc'ed string variables.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1958 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent f02d1edd
...@@ -67,18 +67,6 @@ struct parspec { ...@@ -67,18 +67,6 @@ struct parspec {
static struct params master; static struct params master;
/* XXX: Far too generic to live here ? */
static void
replace(char **p, const char *q)
{
AN(*q);
if (*p != NULL)
free(*p);
*p = strdup(q);
AN(*p);
}
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
...@@ -184,7 +172,7 @@ tweak_user(struct cli *cli, struct parspec *par, const char *arg) ...@@ -184,7 +172,7 @@ tweak_user(struct cli *cli, struct parspec *par, const char *arg)
cli_result(cli, CLIS_PARAM); cli_result(cli, CLIS_PARAM);
return; return;
} }
replace(&master.user, pw->pw_name); REPLACE(master.user, pw->pw_name);
master.uid = pw->pw_uid; master.uid = pw->pw_uid;
master.gid = pw->pw_gid; master.gid = pw->pw_gid;
...@@ -192,7 +180,7 @@ tweak_user(struct cli *cli, struct parspec *par, const char *arg) ...@@ -192,7 +180,7 @@ tweak_user(struct cli *cli, struct parspec *par, const char *arg)
if ((gr = getgrgid(pw->pw_gid)) != NULL && if ((gr = getgrgid(pw->pw_gid)) != NULL &&
(gr = getgrnam(gr->gr_name)) != NULL && (gr = getgrnam(gr->gr_name)) != NULL &&
gr->gr_gid == pw->pw_gid) gr->gr_gid == pw->pw_gid)
replace(&master.group, gr->gr_name); REPLACE(master.group, gr->gr_name);
} else if (master.user) { } else if (master.user) {
cli_out(cli, "%s (%d)", master.user, (int)master.uid); cli_out(cli, "%s (%d)", master.user, (int)master.uid);
} else { } else {
...@@ -226,7 +214,7 @@ tweak_group(struct cli *cli, struct parspec *par, const char *arg) ...@@ -226,7 +214,7 @@ tweak_group(struct cli *cli, struct parspec *par, const char *arg)
cli_result(cli, CLIS_PARAM); cli_result(cli, CLIS_PARAM);
return; return;
} }
replace(&master.group, gr->gr_name); REPLACE(master.group, gr->gr_name);
master.gid = gr->gr_gid; master.gid = gr->gr_gid;
} else if (master.group) { } else if (master.group) {
cli_out(cli, "%s (%d)", master.group, (int)master.gid); cli_out(cli, "%s (%d)", master.group, (int)master.gid);
...@@ -458,7 +446,7 @@ tweak_listen_address(struct cli *cli, struct parspec *par, const char *arg) ...@@ -458,7 +446,7 @@ tweak_listen_address(struct cli *cli, struct parspec *par, const char *arg)
return; return;
} }
replace(&master.listen_address, arg); REPLACE(master.listen_address, arg);
clean_listen_sock_head(&heritage.socks); clean_listen_sock_head(&heritage.socks);
heritage.nsocks = 0; heritage.nsocks = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment