docs/Writerside/topics/buffer.h.md

changeset 1575
dde0c67a449b
parent 1571
25ead2ffb9b5
equal deleted inserted replaced
1574:cfbf4a3a9c11 1575:dde0c67a449b
192 The function `cxBufferPutString()` is a convenience function, 192 The function `cxBufferPutString()` is a convenience function,
193 that uses stdlib `strlen()` to compute the length of `str` and then invokes `cxBufferWrite()`. 193 that uses stdlib `strlen()` to compute the length of `str` and then invokes `cxBufferWrite()`.
194 194
195 All the above functions advance the buffer position by the number of bytes written 195 All the above functions advance the buffer position by the number of bytes written
196 and cause the _size_ of the buffer to grow, if necessary, to contain all written bytes. 196 and cause the _size_ of the buffer to grow, if necessary, to contain all written bytes.
197 On the other hand, `cxBufferTerminate()` writes a zero-byte at the current position, 197 On the other hand, `cxBufferTerminate()` writes a zero-byte at the current position and shrinks the buffer,
198 effectively creating a zero-terminated string whose size equals the buffer size. 198 effectively creating a zero-terminated string whose size equals the buffer size.
199
200 > If you use cxBufferTerminate() on a buffer with the `CX_BUFFER_COPY_ON_EXTEND` flag set, the shrink operation is skipped.
201 > Using `cxBufferTerminate()` on a buffer with the `CX_BUFFER_COPY_ON_WRITE` flag set, will copy the entire memory just to add the zero-terminator.
199 202
200 The function `cxBufferAppend()` writes the data to the end of the buffer (given by its size) regardless of the current position, 203 The function `cxBufferAppend()` writes the data to the end of the buffer (given by its size) regardless of the current position,
201 and it also does _not_ advance the position. 204 and it also does _not_ advance the position.
202 205
203 ## Read 206 ## Read

mercurial