diff -r c065d196a2c8 -r 06091e067bee src/buffer.c --- a/src/buffer.c Fri Dec 20 13:13:38 2024 +0100 +++ b/src/buffer.c Fri Dec 20 15:00:05 2024 +0100 @@ -83,6 +83,7 @@ if (buffer->flags & CX_BUFFER_FREE_CONTENTS) { cxFree(buffer->allocator, buffer->bytes); } + memset(buffer, 0, sizeof(CxBuffer)); } CxBuffer *cxBufferCreate( @@ -106,8 +107,9 @@ void cxBufferFree(CxBuffer *buffer) { if (buffer == NULL) return; + const CxAllocator *allocator = buffer->allocator; cxBufferDestroy(buffer); - cxFree(buffer->allocator, buffer); + cxFree(allocator, buffer); } int cxBufferSeek( @@ -331,6 +333,19 @@ } +size_t cxBufferAppend( + const void *ptr, + size_t size, + size_t nitems, + CxBuffer *buffer +) { + size_t pos = buffer->pos; + buffer->pos = buffer->size; + size_t written = cxBufferWrite(ptr, size, nitems, buffer); + buffer->pos = pos; + return written; +} + int cxBufferPut( CxBuffer *buffer, int c