add documentation for reset and clear

Tue, 25 Mar 2025 22:11:06 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 25 Mar 2025 22:11:06 +0100
changeset 1261
6bbc308b7a20
parent 1260
56a019cdb055
child 1262
7cc81244b28a

add documentation for reset and clear

relates to #451

docs/Writerside/topics/buffer.h.md file | annotate | diff | comparison | revisions
--- 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);
 ```
 
-<warning>
-TODO: document
-</warning>
+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
 

mercurial