[master] 48b9d1bf5 Promote the null blob to vrt

Nils Goroll nils.goroll at uplex.de
Wed Jun 2 13:37:05 UTC 2021


commit 48b9d1bf538fe563f505b75043f297d91690caa3
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Jun 2 15:21:12 2021 +0200

    Promote the null blob to vrt

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 4939e6dd5..7b334e4e2 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -60,6 +60,11 @@ const struct strands *vrt_null_strands = &(struct strands){
 	.n = 0,
 	.p = (const char *[1]){NULL}
 };
+const struct vrt_blob *vrt_null_blob = &(struct vrt_blob){
+	.type = VRT_NULL_BLOB_TYPE,
+	.len = 0,
+	.blob = "\0"
+};
 
 /*--------------------------------------------------------------------*/
 
diff --git a/include/vrt.h b/include/vrt.h
index 9d2c87e98..e2c3646c9 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -55,6 +55,8 @@
  *
  * NEXT (2021-09-15)
  *	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)
  *	Move VRT_synth_page() to deprecated status
  *	Add VRT_synth_strands() and VRT_synth_blob()
@@ -271,6 +273,9 @@ struct vrt_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
  * C-types.  The python scripts read these from here.
diff --git a/vmod/vmod_blob.c b/vmod/vmod_blob.c
index 8274ea6f3..acf7469bd 100644
--- a/vmod/vmod_blob.c
+++ b/vmod/vmod_blob.c
@@ -114,13 +114,6 @@ static const struct vmod_blob_fptr {
 
 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
 parse_encoding(VCL_ENUM e)
 {
@@ -235,7 +228,7 @@ vmod_blob__init(VRT_CTX, struct vmod_blob_blob **blobp, const char *vcl_name,
 	}
 	if (len == 0) {
 		free(buf);
-		memcpy(&b->blob, null_blob, sizeof b->blob);
+		memcpy(&b->blob, vrt_null_blob, sizeof b->blob);
 		return;
 	}
 	b->blob.len = len;
@@ -359,7 +352,7 @@ vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, VCL_STRANDS strings)
 	}
 	if (len == 0) {
 		WS_Release(ctx->ws, 0);
-		return (null_blob);
+		return (vrt_null_blob);
 	}
 	WS_Release(ctx->ws, len);
 
@@ -547,7 +540,7 @@ vmod_sub(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off)
 	}
 
 	if (n == 0)
-		return (null_blob);
+		return (vrt_null_blob);
 
 
 	return (VRT_blob(ctx, "blob.sub",


More information about the varnish-commit mailing list