diff options
author | Tony Garnock-Jones <tonyg@kcbbs.gen.nz> | 2009-05-06 21:36:45 +0100 |
---|---|---|
committer | Tony Garnock-Jones <tonyg@kcbbs.gen.nz> | 2009-05-06 21:36:45 +0100 |
commit | dc04434f7398528ef69954f0f840ac9ce5847347 (patch) | |
tree | cf9a720a30e564e4314ace6045aa98c3416f268e /librabbitmq/amqp_table.c | |
parent | 3238a4fb8525a7da066528c4f735412d4fabadfb (diff) | |
download | rabbitmq-c-github-ask-dc04434f7398528ef69954f0f840ac9ce5847347.tar.gz |
Better support for tables
Diffstat (limited to 'librabbitmq/amqp_table.c')
-rw-r--r-- | librabbitmq/amqp_table.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/librabbitmq/amqp_table.c b/librabbitmq/amqp_table.c index e881f7b..16d85ff 100644 --- a/librabbitmq/amqp_table.c +++ b/librabbitmq/amqp_table.c @@ -7,6 +7,8 @@ #include "amqp.h" #include "amqp_private.h" +#include <assert.h> + #define INITIAL_TABLE_SIZE 16 int amqp_decode_table(amqp_bytes_t encoded, @@ -148,3 +150,21 @@ int amqp_encode_table(amqp_bytes_t encoded, *offsetptr = offset; return 0; } + +int amqp_table_entry_cmp(void const *entry1, void const *entry2) { + amqp_table_entry_t const *p1 = (amqp_table_entry_t const *) entry1; + amqp_table_entry_t const *p2 = (amqp_table_entry_t const *) entry2; + + int d; + int minlen; + + minlen = p1->key.len; + if (p2->key.len < minlen) minlen = p2->key.len; + + d = memcmp(p1->key.bytes, p2->key.bytes, minlen); + if (d != 0) { + return d; + } + + return p1->key.len - p2->key.len; +} |