]> err.no Git - varnish/commitdiff
Use REPLACE macro to manipulate malloc'ed string variables.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 20 Sep 2007 07:03:09 +0000 (07:03 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 20 Sep 2007 07:03:09 +0000 (07:03 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1958 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/mgt_param.c

index e3b8676a7f4bf29c78ad23aca11d02826e94f1ac..466089c8124bdadd383d2c7d5e63018c7a96f719 100644 (file)
@@ -67,18 +67,6 @@ struct parspec {
 
 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
@@ -184,7 +172,7 @@ tweak_user(struct cli *cli, struct parspec *par, const char *arg)
                        cli_result(cli, CLIS_PARAM);
                        return;
                }
-               replace(&master.user, pw->pw_name);
+               REPLACE(master.user, pw->pw_name);
                master.uid = pw->pw_uid;
                master.gid = pw->pw_gid;
 
@@ -192,7 +180,7 @@ tweak_user(struct cli *cli, struct parspec *par, const char *arg)
                if ((gr = getgrgid(pw->pw_gid)) != NULL &&
                    (gr = getgrnam(gr->gr_name)) != NULL &&
                    gr->gr_gid == pw->pw_gid) 
-                       replace(&master.group, gr->gr_name);
+                       REPLACE(master.group, gr->gr_name);
        } else if (master.user) {
                cli_out(cli, "%s (%d)", master.user, (int)master.uid);
        } else {
@@ -226,7 +214,7 @@ tweak_group(struct cli *cli, struct parspec *par, const char *arg)
                        cli_result(cli, CLIS_PARAM);
                        return;
                }
-               replace(&master.group, gr->gr_name);
+               REPLACE(master.group, gr->gr_name);
                master.gid = gr->gr_gid;
        } else if (master.group) {
                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)
                return;
        }
 
-       replace(&master.listen_address, arg);
+       REPLACE(master.listen_address, arg);
 
        clean_listen_sock_head(&heritage.socks);
        heritage.nsocks = 0;