diff options
-rw-r--r-- | librabbitmq/amqp.h | 2 | ||||
-rw-r--r-- | librabbitmq/amqp_mem.c | 11 |
2 files changed, 13 insertions, 0 deletions
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); +} |