diff -r d8044fd5005c -r 67fa386ce600 src/cx/buffer.h --- a/src/cx/buffer.h Mon Dec 09 23:31:42 2024 +0100 +++ b/src/cx/buffer.h Tue Dec 10 00:07:16 2024 +0100 @@ -427,14 +427,14 @@ * * The least significant byte of the argument is written to the buffer. If the * end of the buffer is reached and #CX_BUFFER_AUTO_EXTEND feature is enabled, - * the buffer capacity is extended by cxBufferMinimumCapacity(). If the feature is - * disabled or buffer extension fails, \c EOF is returned. + * the buffer capacity is extended by cxBufferMinimumCapacity(). If the feature + * is disabled or buffer extension fails, \c EOF is returned. * * On successful write, the position of the buffer is increased. * * @param buffer the buffer to write to * @param c the character to write - * @return the byte that has bean written or \c EOF when the end of the stream is + * @return the byte that has been written or \c EOF when the end of the stream is * reached and automatic extension is not enabled or not possible */ cx_attr_nonnull @@ -444,6 +444,21 @@ ); /** + * Writes a terminating zero to a buffer. + * + * On successful write, \em neither the position \em nor the size of the buffer is + * increased. + * + * The purpose of this function is to have the written data ready to be used as + * a C string. + * + * @param buffer the buffer to write to + * @return zero, if the terminator could be written, non-zero otherwise + */ +cx_attr_nonnull +int cxBufferTerminate(CxBuffer *buffer); + +/** * Writes a string to a buffer. * * @param buffer the buffer