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