From e4ee891759b08d3edb258b34f00b4ae8e3298d06 Mon Sep 17 00:00:00 2001 From: Zachary T Welch Date: Sat, 14 Nov 2009 10:27:34 -0800 Subject: improve buf_cmp and buf_cmp_mask helpers Rewrite buf_cmp to use memcpy for bulk of comparison. Add static helper to perform comparison of trailing byte, which uses another static helper to perform a maksed comparison. The masked comparison helper is used by the buf_cmp_mask to simplify its loop. Improve types to use void *, unsigned, and return bool. --- src/helper/binarybuffer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/helper/binarybuffer.h') diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 49050074..a51c2e57 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -70,9 +70,9 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, /// flip_u32 inverts the bit order inside a 32-bit word (31..0 -> 0..31) uint32_t flip_u32(uint32_t value, unsigned int num); -int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size); -int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2, - const uint8_t *mask, int size); +bool buf_cmp(const void *buf1, const void *buf2, unsigned size); +bool buf_cmp_mask(const void *buf1, const void *buf2, + const void *mask, unsigned size); uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size); uint8_t* buf_set_ones(uint8_t *buf, int count); -- cgit v1.2.3