109 void cxBufferReset(CxBuffer *buffer); |
109 void cxBufferReset(CxBuffer *buffer); |
110 |
110 |
111 void cxBufferClear(CxBuffer *buffer); |
111 void cxBufferClear(CxBuffer *buffer); |
112 ``` |
112 ``` |
113 |
113 |
114 <warning> |
114 The function `cxBufferReset()` sets both size and position of the buffer to zero, |
115 TODO: document |
115 and `cxBufferClear()` additionally uses `memset()` to set every byte in the buffer to zero. |
116 </warning> |
116 |
|
117 > When clearing the buffer, only the "live" data, i.e. bytes with indices `[0..size)`, are cleared. |
|
118 > If you which to clear the entire buffer's memory, you would need to set the size to the capacity, first. |
|
119 |
|
120 > If the `CX_BUFFER_COPY_ON_WRITE` flag is set, `cxBufferClear()` behaves exactly like `cxBufferReset()`, |
|
121 > because writing to the contents is disallowed. |
|
122 >{style="note"} |
117 |
123 |
118 ## Random Access |
124 ## Random Access |
119 |
125 |
120 ```C |
126 ```C |
121 #include <cx/buffer.h> |
127 #include <cx/buffer.h> |