--- a/src/cx/buffer.h Fri Dec 20 13:13:38 2024 +0100 +++ b/src/cx/buffer.h Fri Dec 20 15:00:05 2024 +0100 @@ -443,6 +443,32 @@ ); /** + * Appends data to a CxBuffer. + * + * The data is always appended to current data within the buffer, + * regardless of the current position. + * This is especially useful when the buffer is primarily meant for reading + * while additional data is added to the buffer occasionally. + * Consequently, the position of the buffer is unchanged after this operation. + * + * \note The signature is compatible with the fwrite() family of functions. + * + * @param ptr a pointer to the memory area containing the bytes to be written + * @param size the length of one element + * @param nitems the element count + * @param buffer the CxBuffer to write to + * @return the total count of elements written + * @see cxBufferWrite() + */ +cx_attr_nonnull +size_t cxBufferAppend( + const void *ptr, + size_t size, + size_t nitems, + CxBuffer *buffer +); + +/** * Reads data from a CxBuffer. * * The position of the buffer is increased by the number of bytes read.