[ccan] [PATCH 1/9] bytestring: Add bytestring_byte() function
Brad Hards
bradh at frogmouth.net
Mon Jul 28 21:45:00 EST 2014
On Mon, 28 Jul 2014 07:59:49 PM David Gibson wrote:
> Implement a bytestring_byte() function to extract a single byte / character
> from a bytestring.
>
> Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
> ---
> ccan/bytestring/bytestring.h | 15 +++++++++++++++
> ccan/bytestring/test/run.c | 10 +++++++++-
> 2 files changed, 24 insertions(+), 1 deletion(-)
>
> diff --git a/ccan/bytestring/bytestring.h b/ccan/bytestring/bytestring.h
> index 63472fe..93736d8 100644
> --- a/ccan/bytestring/bytestring.h
> +++ b/ccan/bytestring/bytestring.h
> @@ -5,6 +5,7 @@
> #include <stdlib.h>
> #include <string.h>
> #include <stdbool.h>
> +#include <assert.h>
>
> #include <ccan/array_size/array_size.h>
>
> @@ -80,4 +81,18 @@ static inline bool bytestring_eq(struct bytestring a,
> struct bytestring b) && (memcmp(a.ptr, b.ptr, a.len) == 0);
> }
>
> +/**
> + * bytestring_byte - extract a byte from a bytestring
> + * @s: bytestring
> + * @n: index
> + *
> + * Return te @n-th byte from @s. Aborts (via assert) if @n is out of
Typo: te -> the
More information about the ccan
mailing list