summaryrefslogtreecommitdiff
path: root/src/helper/binarybuffer.h
diff options
context:
space:
mode:
authorZachary T Welch <zw@superlucidity.net>2009-11-14 10:27:34 -0800
committerZachary T Welch <zw@superlucidity.net>2009-11-16 00:46:33 -0800
commite4ee891759b08d3edb258b34f00b4ae8e3298d06 (patch)
treeeb7d4b3636fc25753fa48cbe643e2760a8fafe64 /src/helper/binarybuffer.h
parentd50caa97d17187ed96746cc1527e5dbf57d4a81a (diff)
downloadopenocd+libswd-e4ee891759b08d3edb258b34f00b4ae8e3298d06.tar.gz
openocd+libswd-e4ee891759b08d3edb258b34f00b4ae8e3298d06.tar.bz2
openocd+libswd-e4ee891759b08d3edb258b34f00b4ae8e3298d06.tar.xz
openocd+libswd-e4ee891759b08d3edb258b34f00b4ae8e3298d06.zip
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.
Diffstat (limited to 'src/helper/binarybuffer.h')
-rw-r--r--src/helper/binarybuffer.h6
1 files changed, 3 insertions, 3 deletions
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);