Skip to content

Commit

Permalink
Use WS_VSB for saintmode.status
Browse files Browse the repository at this point in the history
  • Loading branch information
nigoroll authored and Guillaume Quintard committed Oct 20, 2020
1 parent a5205b4 commit d3ebb9f
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions src/vmod_saintmode.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,12 @@ vmod_status(VRT_CTX, struct vmod_priv *priv)
{
struct saintmode_objs *sm_objs;
struct vmod_saintmode_saintmode *sm;
struct vsb *vsb;
void *p;
struct vsb vsb[1];

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CAST_OBJ_NOTNULL(sm_objs, priv->priv, SAINTMODE_OBJS_MAGIC);

vsb = VSB_new_auto();
AN(vsb);
WS_VSB_new(vsb, ctx->ws);
VSB_cat(vsb, "{\n\t\"saintmode\": [\n");

VTAILQ_FOREACH(sm, &sm_objs->sm_list, list) {
Expand All @@ -179,15 +177,7 @@ vmod_status(VRT_CTX, struct vmod_priv *priv)
VSB_cat(vsb, "\n");
}

VSB_cat(vsb, "\t]\n}\n");
VSB_finish(vsb);

p = WS_Copy(ctx->ws, VSB_data(vsb), -1);
if (p == NULL)
VSLb(ctx->vsl, SLT_VCL_Log,
"saintmode.vmod_status: workspace overflow");
VSB_destroy(&vsb);
return (p);
return (WS_VSB_finish(vsb, ctx->ws, NULL));
}

VCL_INT
Expand Down

0 comments on commit d3ebb9f

Please sign in to comment.