# HG changeset patch # User Mike Becker # Date 1742937066 -3600 # Node ID 6bbc308b7a2067cd98fdaa6f1ff979a3d3aa4f3a # Parent 56a019cdb055b297b50c04625b45e73f866dd1f3 add documentation for reset and clear relates to #451 diff -r 56a019cdb055 -r 6bbc308b7a20 docs/Writerside/topics/buffer.h.md --- a/docs/Writerside/topics/buffer.h.md Mon Mar 24 20:16:36 2025 +0100 +++ b/docs/Writerside/topics/buffer.h.md Tue Mar 25 22:11:06 2025 +0100 @@ -111,9 +111,15 @@ void cxBufferClear(CxBuffer *buffer); ``` - -TODO: document - +The function `cxBufferReset()` sets both size and position of the buffer to zero, +and `cxBufferClear()` additionally uses `memset()` to set every byte in the buffer to zero. + +> When clearing the buffer, only the "live" data, i.e. bytes with indices `[0..size)`, are cleared. +> If you which to clear the entire buffer's memory, you would need to set the size to the capacity, first. + +> If the `CX_BUFFER_COPY_ON_WRITE` flag is set, `cxBufferClear()` behaves exactly like `cxBufferReset()`, +> because writing to the contents is disallowed. +>{style="note"} ## Random Access