[ccan] [PATCH 01/11] bytestring: Add bytestring_byte() function

Brad Hards bradh at frogmouth.net
Sun Oct 12 10:56:42 AEDT 2014


On Sat, 11 Oct 2014 06:43:26 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..77435c9 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
Perhaps "gets" or "selects" rather than extracts, which suggests get-and-
remove.

Brad


More information about the ccan mailing list