r1958 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Thu Sep 20 09:03:09 CEST 2007


Author: phk
Date: 2007-09-20 09:03:09 +0200 (Thu, 20 Sep 2007)
New Revision: 1958

Modified:
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Use REPLACE macro to manipulate malloc'ed string variables.


Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2007-09-20 07:02:35 UTC (rev 1957)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2007-09-20 07:03:09 UTC (rev 1958)
@@ -67,18 +67,6 @@
 
 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 @@
 			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 @@
 		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 @@
 			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 @@
 		return;
 	}
 
-	replace(&master.listen_address, arg);
+	REPLACE(master.listen_address, arg);
 
 	clean_listen_sock_head(&heritage.socks);
 	heritage.nsocks = 0;




More information about the varnish-commit mailing list