X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fmem%2Fmem.h;h=1afe508b3a097beefdbf93660165c7146fdb3f25;hp=8d6bba943c8eab31243cadfdec3998cc1ed809f2;hb=4ad5144790a12523f8a7c24c469a34907b6942a6;hpb=2c20abc2e2fdaf1888472968e811d00260dcf8fa diff --git a/ccan/mem/mem.h b/ccan/mem/mem.h index 8d6bba94..1afe508b 100644 --- a/ccan/mem/mem.h +++ b/ccan/mem/mem.h @@ -183,4 +183,21 @@ static inline bool memends(const void *s, size_t s_len, const void *suffix, size suffix, suffix_len) == 0); } +/** + * memends_str - Does this byte array end with a string suffix? + * @a: byte array + * @al: length in bytes + * @s: string suffix + * + * Example: + * if (memends_str(somebytes, bytes_len, "It")) { + * printf("somebytes ends with with 'It'\n"); + * } + */ +PURE_FUNCTION +static inline bool memends_str(const void *a, size_t al, const char *s) +{ + return memends(a, al, s, strlen(s)); +} + #endif /* CCAN_MEM_H */