X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fbytestring%2Fbytestring.h;fp=ccan%2Fbytestring%2Fbytestring.h;h=dd1f913ca45ee2f0dbe7d66f50f175256927095b;hp=fd5187701b3430bd03f5cc60be080f0dfdc57b49;hb=2ecae4f3ae8880196794704029c90d0285c8cb80;hpb=846f605e6ed459f1276c218cb1421514d6b43c90 diff --git a/ccan/bytestring/bytestring.h b/ccan/bytestring/bytestring.h index fd518770..dd1f913c 100644 --- a/ccan/bytestring/bytestring.h +++ b/ccan/bytestring/bytestring.h @@ -55,6 +55,18 @@ bytestring(const char *p, size_t l) */ #define BYTESTRING(s) (bytestring((s), ARRAY_SIZE(s) - 1)) +/** + * BYTESTRING_INIT - bytestring initializer + * @s: string literal + * + * Produces an initializer for a bytestring from a literal string. + * The resulting bytestring will not include the terminating \0, but + * will include any internal \0s. + * + * Example: + * static const struct bytestring CONSTANT = BYTESTRING_INIT("CONSTANT"); + */ +#define BYTESTRING_INIT(s) { .ptr = (s), .len = ARRAY_SIZE(s) - 1} /** * bytestring_from_string - construct a bytestring from a NUL terminated string