r1996 - in branches/1.1: . bin/varnishd include
des at projects.linpro.no
des at projects.linpro.no
Sun Sep 23 15:22:11 CEST 2007
Author: des
Date: 2007-09-23 15:22:11 +0200 (Sun, 23 Sep 2007)
New Revision: 1996
Modified:
branches/1.1/
branches/1.1/bin/varnishd/mgt_param.c
branches/1.1/include/miniobj.h
Log:
Merged revisions 1957-1958 via svnmerge from
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache
........
r1957 | phk | 2007-09-20 09:02:35 +0200 (Thu, 20 Sep 2007) | 2 lines
Add a REPLACE() macro, for manipulating malloced string variables.
........
r1958 | phk | 2007-09-20 09:03:09 +0200 (Thu, 20 Sep 2007) | 2 lines
Use REPLACE macro to manipulate malloc'ed string variables.
........
Property changes on: branches/1.1
___________________________________________________________________
Name: svnmerge-integrated
- /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1984,1986-1989,1992-1994
+ /trunk/varnish-cache:1-1722,1727-1729,1738,1743-1777,1779-1798,1800-1808,1810-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1984,1986-1989,1992-1994
Modified: branches/1.1/bin/varnishd/mgt_param.c
===================================================================
--- branches/1.1/bin/varnishd/mgt_param.c 2007-09-23 13:20:12 UTC (rev 1995)
+++ branches/1.1/bin/varnishd/mgt_param.c 2007-09-23 13:22:11 UTC (rev 1996)
@@ -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;
Modified: branches/1.1/include/miniobj.h
===================================================================
--- branches/1.1/include/miniobj.h 2007-09-23 13:20:12 UTC (rev 1995)
+++ branches/1.1/include/miniobj.h 2007-09-23 13:22:11 UTC (rev 1996)
@@ -30,10 +30,21 @@
CHECK_OBJ((to), (type_magic)); \
} while (0);
-#define CAST_OBJ_NOTNULL(to, from, type_magic) \
+#define CAST_OBJ_NOTNULL(to, from, type_magic) \
do { \
(to) = (from); \
assert((to) != NULL); \
CHECK_OBJ((to), (type_magic)); \
} while (0);
+#define REPLACE(ptr, val) \
+ do { \
+ if ((ptr) != NULL) \
+ free(ptr); \
+ if ((val) != NULL) { \
+ ptr = strdup(val); \
+ AN((ptr)); \
+ } else { \
+ ptr = NULL; \
+ } \
+ } while (0);
More information about the varnish-commit
mailing list