Mailing List Archive

r1697 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2007-07-15 09:52:11 +0200 (Sun, 15 Jul 2007)
New Revision: 1697

Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Make the header-gluing code more readable.


Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-07-15 07:51:36 UTC (rev 1696)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2007-07-15 07:52:11 UTC (rev 1697)
@@ -123,28 +123,30 @@

u = WS_Reserve(hp->ws, 0);
e = b = hp->ws->f;
- *e = '\0';
+ e += u;
if (h != NULL) {
x = strlen(h);
- if (x + 2 < u) {
- memcpy(e, h, x);
- e[x] = ' ';
- e[x + 1] = '\0';
- }
- e += x + 1;
+ if (b + x < e)
+ memcpy(b, h, x);
+ b += x;
+ if (b + 1 < e)
+ *b++ = ' ';
}
while (p != NULL) {
x = strlen(p);
- if (x + 1 < u)
- memcpy(e, p, x);
- e += x;
+ if (b + x < e)
+ memcpy(b, p, x);
+ b += x;
p = va_arg(ap, const char *);
}
- *e = '\0';
- if (e > b + u) {
+ if (b + 1 < e)
+ *b++ = '\0';
+ if (b > e) {
WS_Release(hp->ws, 0);
return (NULL);
} else {
+ e = b;
+ b = hp->ws->f;
WS_Release(hp->ws, 1 + e - b);
return (b);
}