X-Git-Url: https://develop.uap-core.de/gitweb/uwplayer.git/blobdiff_plain/5cb490b04836ef624cdd0ba975ee5c2ff2e51a23..01d5015ba093f8c5fdb18b669943c7da6450e72f:/ucx/cx/buffer.h diff --git a/ucx/cx/buffer.h b/ucx/cx/buffer.h index d4be652..a000b2f 100644 --- a/ucx/cx/buffer.h +++ b/ucx/cx/buffer.h @@ -164,16 +164,52 @@ int cxBufferInit( ); /** + * Allocates and initializes a fresh buffer. + * + * \note You may provide \c NULL as argument for \p space. + * Then this function will allocate the space and enforce + * the #CX_BUFFER_FREE_CONTENTS flag. + * + * @param space pointer to the memory area, or \c NULL to allocate + * new memory + * @param capacity the capacity of the buffer + * @param allocator the allocator to use for allocating the structure and the automatic + * memory management within the buffer. If \c NULL, the default heap allocator will be used. + * @param flags buffer features (see cx_buffer_s.flags) + * @return a pointer to the buffer on success, \c NULL if a required allocation failed + */ +CxBuffer *cxBufferCreate( + void *space, + size_t capacity, + CxAllocator const *allocator, + int flags +); + +/** * Destroys the buffer contents. * * Has no effect if the #CX_BUFFER_FREE_CONTENTS feature is not enabled. + * If you want to free the memory of the entire buffer, use cxBufferFree(). * * @param buffer the buffer which contents shall be destroyed + * @see cxBufferInit() */ __attribute__((__nonnull__)) void cxBufferDestroy(CxBuffer *buffer); /** + * Deallocates the buffer. + * + * If the #CX_BUFFER_FREE_CONTENTS feature is enabled, this function also destroys + * the contents. If you \em only want to destroy the contents, use cxBufferDestroy(). + * + * @param buffer the buffer to deallocate + * @see cxBufferCreate() + */ +__attribute__((__nonnull__)) +void cxBufferFree(CxBuffer *buffer); + +/** * Shifts the contents of the buffer by the given offset. * * If the offset is positive, the contents are shifted to the right.