X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fmem%2Fmem.h;h=06a1b7a1f2411150147d043cc0bfdbf7635967e8;hb=ca2551bcedb6ebd66814a2d4fdce7494b19d9b0d;hp=68a4aa3c18885c207a9fd11828bc5174bead6905;hpb=e8d1e7304feb9318a841ad4a7d5a8773271ab814;p=ccan diff --git a/ccan/mem/mem.h b/ccan/mem/mem.h index 68a4aa3c..06a1b7a1 100644 --- a/ccan/mem/mem.h +++ b/ccan/mem/mem.h @@ -144,6 +144,19 @@ static inline bool memstarts(void const *data, size_t data_len, * } */ PURE_FUNCTION +bool memeqzero(const void *data, size_t length); + +/** + * memeqzero - Is a byte array all zeroes? + * @data: byte array + * @length: length of @data in bytes + * + * Example: + * if (memeqzero(somebytes, bytes_len)) { + * printf("somebytes == 0!\n"); + * } + */ +PURE_FUNCTION static inline bool memeqstr(const void *data, size_t length, const char *string) { return memeq(data, length, string, strlen(string));