[ccan] [PATCH 2/3] bytestring: use newly added mem helpers
David Gibson
david at gibson.dropbear.id.au
Wed Aug 19 09:08:45 AEST 2015
On Mon, Aug 17, 2015 at 08:33:30PM -0400, Cody P Schafer wrote:
> Signed-off-by: Cody P Schafer <dev at codyps.com>
Reviwed-by: David Gibson <david at gibson.dropbear.id.au>
> ---
> ccan/bytestring/bytestring.h | 9 +++------
> 1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/ccan/bytestring/bytestring.h b/ccan/bytestring/bytestring.h
> index dd1f913..bc99e79 100644
> --- a/ccan/bytestring/bytestring.h
> +++ b/ccan/bytestring/bytestring.h
> @@ -94,8 +94,7 @@ static inline struct bytestring bytestring_from_string(const char *s)
> */
> static inline bool bytestring_eq(struct bytestring a, struct bytestring b)
> {
> - return (a.len == b.len)
> - && (memcmp(a.ptr, b.ptr, a.len) == 0);
> + return memeq(a.ptr, a.len, b.ptr, b.len);
> }
>
> /**
> @@ -149,8 +148,7 @@ static inline struct bytestring bytestring_slice(struct bytestring s,
> static inline bool bytestring_starts(struct bytestring s,
> struct bytestring prefix)
> {
> - return (s.len >= prefix.len) && (memcmp(s.ptr,
> - prefix.ptr, prefix.len) == 0);
> + return memstarts(s.ptr, s.len, prefix.ptr, prefix.len);
> }
>
> /**
> @@ -163,8 +161,7 @@ static inline bool bytestring_starts(struct bytestring s,
> static inline bool bytestring_ends(struct bytestring s,
> struct bytestring suffix)
> {
> - return (s.len >= suffix.len) && (memcmp(s.ptr + s.len - suffix.len,
> - suffix.ptr, suffix.len) == 0);
> + return memends(s.ptr, s.len, suffix.ptr, suffix.len);
> }
>
> /**
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.ozlabs.org/pipermail/ccan/attachments/20150818/1dade5d0/attachment.sig>
More information about the ccan
mailing list