Promote the null blob to vrt

parent 05e10eee
...@@ -60,6 +60,11 @@ const struct strands *vrt_null_strands = &(struct strands){ ...@@ -60,6 +60,11 @@ const struct strands *vrt_null_strands = &(struct strands){
.n = 0, .n = 0,
.p = (const char *[1]){NULL} .p = (const char *[1]){NULL}
}; };
const struct vrt_blob *vrt_null_blob = &(struct vrt_blob){
.type = VRT_NULL_BLOB_TYPE,
.len = 0,
.blob = "\0"
};
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
......
...@@ -55,6 +55,8 @@ ...@@ -55,6 +55,8 @@
* *
* NEXT (2021-09-15) * NEXT (2021-09-15)
* vrt_null_strands added * vrt_null_strands added
* vrt_null_blob added
* VRT_NULL_BLOB_TYPE added as the .type of vrt_null_blob
* 13.0 (2021-03-15) * 13.0 (2021-03-15)
* Move VRT_synth_page() to deprecated status * Move VRT_synth_page() to deprecated status
* Add VRT_synth_strands() and VRT_synth_blob() * Add VRT_synth_strands() and VRT_synth_blob()
...@@ -271,6 +273,9 @@ struct vrt_blob { ...@@ -271,6 +273,9 @@ struct vrt_blob {
const void *blob; const void *blob;
}; };
#define VRT_NULL_BLOB_TYPE 0xfade4fa0
extern const struct vrt_blob *vrt_null_blob;
/*********************************************************************** /***********************************************************************
* This is the central definition of the mapping from VCL types to * This is the central definition of the mapping from VCL types to
* C-types. The python scripts read these from here. * C-types. The python scripts read these from here.
......
...@@ -114,13 +114,6 @@ static const struct vmod_blob_fptr { ...@@ -114,13 +114,6 @@ static const struct vmod_blob_fptr {
static char empty[1] = { '\0' }; static char empty[1] = { '\0' };
static const struct vrt_blob null_blob[1] = {{
#define VMOD_BLOB_NULL_TYPE 0xfade4fa0
.type = VMOD_BLOB_NULL_TYPE,
.len = 0,
.blob = empty,
}};
static enum encoding static enum encoding
parse_encoding(VCL_ENUM e) parse_encoding(VCL_ENUM e)
{ {
...@@ -235,7 +228,7 @@ vmod_blob__init(VRT_CTX, struct vmod_blob_blob **blobp, const char *vcl_name, ...@@ -235,7 +228,7 @@ vmod_blob__init(VRT_CTX, struct vmod_blob_blob **blobp, const char *vcl_name,
} }
if (len == 0) { if (len == 0) {
free(buf); free(buf);
memcpy(&b->blob, null_blob, sizeof b->blob); memcpy(&b->blob, vrt_null_blob, sizeof b->blob);
return; return;
} }
b->blob.len = len; b->blob.len = len;
...@@ -359,7 +352,7 @@ vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, VCL_STRANDS strings) ...@@ -359,7 +352,7 @@ vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, VCL_STRANDS strings)
} }
if (len == 0) { if (len == 0) {
WS_Release(ctx->ws, 0); WS_Release(ctx->ws, 0);
return (null_blob); return (vrt_null_blob);
} }
WS_Release(ctx->ws, len); WS_Release(ctx->ws, len);
...@@ -547,7 +540,7 @@ vmod_sub(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) ...@@ -547,7 +540,7 @@ vmod_sub(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off)
} }
if (n == 0) if (n == 0)
return (null_blob); return (vrt_null_blob);
return (VRT_blob(ctx, "blob.sub", return (VRT_blob(ctx, "blob.sub",
......
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