Mercurial > dovecot > original-hg > dovecot-1.2
changeset 3252:fb9eee567307 HEAD
Added buffer_cmp().
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Sat, 02 Apr 2005 22:29:08 +0300 |
parents | 3544d971e7da |
children | f5a1c3f7fd72 |
files | src/lib/buffer.c src/lib/buffer.h |
diffstat | 2 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/buffer.c Sat Apr 02 20:37:03 2005 +0300 +++ b/src/lib/buffer.c Sat Apr 02 22:29:08 2005 +0300 @@ -281,3 +281,11 @@ return buf->alloc; } + +int buffer_cmp(const buffer_t *buf1, const buffer_t *buf2) +{ + if (buf1->used != buf2->used) + return FALSE; + + return memcmp(buf1->data, buf2->data, buf1->used) == 0; +}
--- a/src/lib/buffer.h Sat Apr 02 20:37:03 2005 +0300 +++ b/src/lib/buffer.h Sat Apr 02 22:29:08 2005 +0300 @@ -79,6 +79,9 @@ /* Returns the current buffer size. */ size_t buffer_get_size(const buffer_t *buf); +/* Returns TRUE if buffer contents are identical. */ +int buffer_cmp(const buffer_t *buf1, const buffer_t *buf2); + /* Returns pointer to beginning of buffer data. Current used size of buffer is stored in used_size if it's non-NULL. */ static inline const void *