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

Make it possible to get the length from WS_VSB_finish() (ie: H2 headers).

parent 4454f75d
......@@ -796,7 +796,7 @@ int WS_Inside(const struct ws *, const void *, const void *);
void WS_Assert_Allocated(const struct ws *ws, const void *ptr, ssize_t len);
void WS_VSB_new(struct vsb *, struct ws *);
char *WS_VSB_finish(struct vsb *, struct ws *);
char *WS_VSB_finish(struct vsb *, struct ws *, size_t *);
static inline char*
WS_Front(const struct ws *ws)
......
......@@ -474,7 +474,7 @@ VRT_StrandsWS(struct ws *ws, const char *h, VCL_STRANDS s)
if (s->p[i] != NULL && *s->p[i] != '\0')
VSB_cat(vsb, s->p[i]);
}
return (WS_VSB_finish(vsb, ws));
return (WS_VSB_finish(vsb, ws, NULL));
}
/*--------------------------------------------------------------------
......
......@@ -352,7 +352,7 @@ WS_Overflowed(const struct ws *ws)
*
* WS_VSB_new(vsb, ctx->ws);
* VSB_printf(vsb, "blablabla");
* p = WS_VSB_finish(vsb);
* p = WS_VSB_finish(vsb, NULL);
* if (p == NULL)
* return (FAILURE);
*/
......@@ -375,7 +375,7 @@ WS_VSB_new(struct vsb *vsb, struct ws *ws)
}
char *
WS_VSB_finish(struct vsb *vsb, struct ws *ws)
WS_VSB_finish(struct vsb *vsb, struct ws *ws, size_t *szp)
{
char *p;
......@@ -384,11 +384,15 @@ WS_VSB_finish(struct vsb *vsb, struct ws *ws)
p = VSB_data(vsb);
if (p == WS_Front(ws)) {
WS_Release(ws, VSB_len(vsb) + 1);
if (szp != NULL)
*szp = VSB_len(vsb);
VSB_delete(vsb);
return (p);
}
}
VSB_delete(vsb);
WS_Release(ws, 0);
if (szp)
*szp = 0;
return (NULL);
}
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