Add gwbuf_compare

With gwbuf_compare the content of two GWBUFs can be compared.
This commit is contained in:
Johan Wikman
2016-12-19 14:22:34 +02:00
parent 3a3632e75e
commit b62db91ab3
3 changed files with 209 additions and 0 deletions

View File

@ -211,6 +211,26 @@ extern void gwbuf_free(GWBUF *buf);
*/
extern GWBUF *gwbuf_clone(GWBUF *buf);
/**
* Compare two GWBUFs. Two GWBUFs are considered identical if their
* content is identical, irrespective of whether one is segmented and
* the other is not.
*
* @param lhs One GWBUF
* @param rhs Another GWBUF
*
* @return 0 if the content is identical,
* -1 if @c lhs is less than @c rhs, and
* 1 if @c lhs is more than @c rhs.
*
* @attention A NULL @c GWBUF is considered to be less than a non-NULL one,
* and a shorter @c GWBUF less than a longer one. Otherwise the
* the sign of the return value is determined by the sign of the
* difference between the first pair of bytes (interpreted as
* unsigned char) that differ in lhs and rhs.
*/
extern int gwbuf_compare(const GWBUF* lhs, const GWBUF* rhs);
/**
* Append a buffer onto a linked list of buffer structures.
*