From fc9a9bbccf1a5ea483ecffd35dd988dffa94362d Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 9 Jan 2010 00:18:47 +0000 Subject: Add amqp_bytes_t utilities. --- librabbitmq/amqp.h | 2 ++ librabbitmq/amqp_mem.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/librabbitmq/amqp.h b/librabbitmq/amqp.h index 643fc39..45e4d63 100644 --- a/librabbitmq/amqp.h +++ b/librabbitmq/amqp.h @@ -238,6 +238,8 @@ extern void amqp_pool_alloc_bytes(amqp_pool_t *pool, size_t amount, amqp_bytes_t extern amqp_bytes_t amqp_cstring_bytes(char const *cstr); extern amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src); +extern amqp_bytes_t amqp_bytes_malloc(size_t amount); +extern void amqp_bytes_free(amqp_bytes_t bytes); #define AMQP_BYTES_FREE(b) \ ({ \ diff --git a/librabbitmq/amqp_mem.c b/librabbitmq/amqp_mem.c index 0e84dd7..5449330 100644 --- a/librabbitmq/amqp_mem.c +++ b/librabbitmq/amqp_mem.c @@ -141,3 +141,14 @@ amqp_bytes_t amqp_bytes_malloc_dup(amqp_bytes_t src) { } return result; } + +amqp_bytes_t amqp_bytes_malloc(size_t amount) { + amqp_bytes_t result; + result.len = amount; + result.bytes = malloc(amount); /* will return NULL if it fails */ + return result; +} + +void amqp_bytes_free(amqp_bytes_t bytes) { + AMQP_BYTES_FREE(bytes); +} -- cgit v1.2.1