diff -r 7084e8e8433c -r 31a8682fffb7 ucx/allocator.h --- a/ucx/allocator.h Mon Jun 02 16:04:11 2014 +0200 +++ b/ucx/allocator.h Tue Jun 10 15:43:13 2014 +0200 @@ -157,6 +157,41 @@ void ucx_default_free(void *ignore, void *data); /** + * Shorthand for calling an allocators malloc function. + * @param allocator the allocator to use + * @param n size of space to allocate + * @return a pointer to the allocated memory area + */ +#define almalloc(allocator, n) ((allocator)->malloc(allocator->pool, n)) + +/** + * Shorthand for calling an allocators calloc function. + * @param allocator the allocator to use + * @param n the count of elements the space should be allocated for + * @param size the size of each element + * @return a pointer to the allocated memory area + */ +#define alcalloc(allocator, n, size) \ + ((allocator)->calloc(allocator->pool, n, size)) + +/** + * Shorthand for calling an allocators realloc function. + * @param allocator the allocator to use + * @param ptr the pointer to the memory area that shall be reallocated + * @param n the new size of the allocated memory area + * @return a pointer to the reallocated memory area + */ +#define alrealloc(allocator, ptr, n) \ + ((allocator)->realloc(allocator->pool, ptr, n)) + +/** + * Shorthand for calling an allocators free function. + * @param allocator the allocator to use + * @param ptr the pointer to the memory area that shall be freed + */ +#define alfree(allocator, ptr) ((allocator)->free(allocator->pool, ptr)) + +/** * Convenient macro for a default allocator struct definition. */ #define UCX_ALLOCATOR_DEFAULT {NULL, \