Commit f02d1edd authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a REPLACE() macro, for manipulating malloced string variables.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1957 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 79833e5a
......@@ -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);
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