5 * bytestring - simple bytestring handling
7 * This code handles manipulation of "bytestrings" represented as a
8 * structure containing a pointer and length. Bytestrings are not
9 * NUL-terminated, and may include internal \0 characters. The main
10 * use case is for referencing sub-sections of a large data buffer
11 * without the inconvenience of manually passing (and returning) both
12 * pointer and length all the time.
14 * Because of this use case, the bytestrings are treated as having
15 * immutable contents (we use a const char pointer). The caller code
16 * is responsible for ensuring that the lifetime of the data
17 * referenced by the bytestrings is long enough not to leave
18 * bytestring structures with a dangling pointer.
21 * const char buf[] = "ABCDEFGH";
22 * struct bytestring abcd = BYTESTRING("ABCD");
24 * assert(bytestring_eq(bytestring(buf, 4), abcd));
26 * License: LGPL (v2.1 or any later version)
27 * Author: David Gibson <david@gibson.dropbear.id.au>
29 int main(int argc, char *argv[])
31 /* Expect exactly one argument */
35 if (strcmp(argv[1], "depends") == 0) {
36 printf("ccan/array_size\n");