--- a/src/cx/buffer.h Sat Oct 11 15:42:48 2025 +0200 +++ b/src/cx/buffer.h Sun Oct 12 20:21:56 2025 +0200 @@ -62,7 +62,7 @@ * If this flag is enabled, the buffer will automatically free its contents when destroyed. * * Do NOT set this flag together with #CX_BUFFER_COPY_ON_WRITE. It will be automatically - * set when the copy-on-write operations is performed. + * set when the copy-on-write operation is performed. */ #define CX_BUFFER_FREE_CONTENTS 0x01 @@ -74,7 +74,7 @@ /** * If this flag is enabled, the buffer will allocate new memory when written to. * - * The current contents of the buffer will be copied to the new memory and the flag + * The current contents of the buffer will be copied to the new memory, and the flag * will be cleared while the #CX_BUFFER_FREE_CONTENTS flag will be set automatically. */ #define CX_BUFFER_COPY_ON_WRITE 0x04 @@ -127,7 +127,7 @@ size_t blkmax; /** - * The target for write function. + * The target for the write function. */ void *target; @@ -202,7 +202,7 @@ * you will need to cast the pointer, and you should set the * #CX_BUFFER_COPY_ON_WRITE flag. * - * You need to set the size manually after initialization, if + * You need to set the size manually after initialization if * you provide @p space which already contains data. * * When you specify stack memory as @p space and decide to use @@ -210,7 +210,7 @@ * #CX_BUFFER_COPY_ON_EXTEND flag, instead of the * #CX_BUFFER_AUTO_EXTEND flag. * - * @note You may provide @c NULL as argument for @p space. + * @note You may provide @c NULL as the argument for @p space. * Then this function will allocate the space and enforce * the #CX_BUFFER_FREE_CONTENTS flag. In that case, specifying * copy-on-write should be avoided, because the allocated @@ -276,9 +276,6 @@ * 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(). * - * @remark As with all free() functions, this accepts @c NULL arguments in which - * case it does nothing. - * * @param buffer the buffer to deallocate * @see cxBufferCreate() */ @@ -296,7 +293,7 @@ * #CX_BUFFER_COPY_ON_EXTEND flag, instead of the * #CX_BUFFER_AUTO_EXTEND flag. * - * @note You may provide @c NULL as argument for @p space. + * @note You may provide @c NULL as the argument for @p space. * Then this function will allocate the space and enforce * the #CX_BUFFER_FREE_CONTENTS flag. * @@ -327,8 +324,8 @@ * If auto extension is enabled, the buffer grows, if necessary. * In case the auto extension fails, this function returns a non-zero value and * no contents are changed. - * If auto extension is disabled, the contents that do not fit into the buffer - * are discarded. + * When the auto extension is disabled, the contents that do not fit into the + * buffer are discarded. * * If the offset is negative, the contents are shifted to the left where the * first @p shift bytes are discarded. @@ -336,15 +333,15 @@ * If this value is larger than the buffer size, the buffer is emptied (but * not cleared, see the security note below). * - * The buffer position gets shifted alongside with the content but is kept + * The buffer position gets shifted alongside the content but is kept * within the boundaries of the buffer. * * @note For situations where @c off_t is not large enough, there are specialized cxBufferShiftLeft() and - * cxBufferShiftRight() functions using a @c size_t as parameter type. + * cxBufferShiftRight() functions using a @c size_t as the parameter type. * * @attention * Security Note: The shifting operation does @em not erase the previously occupied memory cells. - * But you can easily do that manually, e.g. by calling + * But you can do that manually by calling * <code>memset(buffer->bytes, 0, shift)</code> for a right shift or * <code>memset(buffer->bytes + buffer->size, 0, buffer->capacity - buffer->size)</code> * for a left shift. @@ -517,7 +514,7 @@ * Writes data to a CxBuffer. * * If automatic flushing is not enabled, the data is simply written into the - * buffer at the current position and the position of the buffer is increased + * buffer at the current position, and the position of the buffer is increased * by the number of bytes written. * * If flushing is enabled and the buffer needs to flush, the data is flushed to @@ -526,7 +523,7 @@ * data in this buffer is shifted to the beginning of this buffer so that the * newly available space can be used to append as much data as possible. * - * This function only stops writing more elements, when the flush target and this + * This function only stops writing more elements when the flush target and this * buffer are both incapable of taking more data or all data has been written. * * If, after flushing, the number of items that shall be written still exceeds @@ -534,14 +531,14 @@ * to the flush target, if possible. * * The number returned by this function is the number of elements from - * @c ptr that could be written to either the flush target or the buffer - * (so it does not include the number of items that had been already in the buffer - * in were flushed during the process). + * @c ptr that could be written to either the flush target or the buffer. + * That means it does @em not include the number of items that were already in + * the buffer and were also flushed during the process. * * @attention * When @p size is larger than one and the contents of the buffer are not aligned * with @p size, flushing stops after all complete items have been flushed, leaving - * the mis-aligned part in the buffer. + * the misaligned part in the buffer. * Afterward, this function only writes as many items as possible to the buffer. * * @note The signature is compatible with the fwrite() family of functions. @@ -614,19 +611,19 @@ * at position 200. The flush configuration is * @c blkmax=4 and @c blksize=64 . * Assume that the entire flush operation is successful. - * All 200 bytes on the left hand-side from the current + * All 200 bytes on the left-hand-side from the current * position are written. - * That means, the size of the buffer is now 140 and the + * That means the size of the buffer is now 140 and the * position is zero. * * @par Example 2 * Same as Example 1, but now the @c blkmax is 1. - * The size of the buffer is now 276 and the position is 136. + * The size of the buffer is now 276, and the position is 136. * * @par Example 3 * Same as Example 1, but now assume the flush target * only accepts 100 bytes before returning zero. - * That means, the flush operations manages to flush + * That means the flush operation manages to flush * one complete block and one partial block, ending * up with a buffer with size 240 and position 100. * @@ -636,8 +633,8 @@ * @remark When the buffer uses copy-on-write, the memory * is copied first, before attempting any flush. * This is, however, considered an erroneous use of the - * buffer, because it does not make much sense to put - * readonly data into an UCX buffer for flushing, instead + * buffer because it makes little sense to put + * readonly data into an UCX buffer for flushing instead * of writing it directly to the target. * * @param buffer the buffer @@ -678,9 +675,9 @@ * 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. + * is disabled or the buffer extension fails, @c EOF is returned. * - * On successful write, the position of the buffer is increased. + * On successful writing, the position of the buffer is increased. * * If you just want to write a null-terminator at the current position, you * should use cxBufferTerminate() instead. @@ -688,7 +685,7 @@ * @param buffer the buffer to write to * @param c the character to write * @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 + * reached, and automatic extension is not enabled or not possible * @see cxBufferTerminate() */ cx_attr_nonnull