Commit 1b573141 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make the header-gluing code more readable.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1697 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 82698f3c
...@@ -123,28 +123,30 @@ vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap) ...@@ -123,28 +123,30 @@ vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap)
u = WS_Reserve(hp->ws, 0); u = WS_Reserve(hp->ws, 0);
e = b = hp->ws->f; e = b = hp->ws->f;
*e = '\0'; e += u;
if (h != NULL) { if (h != NULL) {
x = strlen(h); x = strlen(h);
if (x + 2 < u) { if (b + x < e)
memcpy(e, h, x); memcpy(b, h, x);
e[x] = ' '; b += x;
e[x + 1] = '\0'; if (b + 1 < e)
} *b++ = ' ';
e += x + 1;
} }
while (p != NULL) { while (p != NULL) {
x = strlen(p); x = strlen(p);
if (x + 1 < u) if (b + x < e)
memcpy(e, p, x); memcpy(b, p, x);
e += x; b += x;
p = va_arg(ap, const char *); p = va_arg(ap, const char *);
} }
*e = '\0'; if (b + 1 < e)
if (e > b + u) { *b++ = '\0';
if (b > e) {
WS_Release(hp->ws, 0); WS_Release(hp->ws, 0);
return (NULL); return (NULL);
} else { } else {
e = b;
b = hp->ws->f;
WS_Release(hp->ws, 1 + e - b); WS_Release(hp->ws, 1 + e - b);
return (b); return (b);
} }
......
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