52 void cxBufferDestroy(CxBuffer *buffer); |
52 void cxBufferDestroy(CxBuffer *buffer); |
53 |
53 |
54 void cxBufferFree(CxBuffer *buffer); |
54 void cxBufferFree(CxBuffer *buffer); |
55 ``` |
55 ``` |
56 |
56 |
57 <warning> |
57 The above functions destroy the buffer and deallocate the buffer's memory when the `CX_BUFFER_FREE_CONTENTS` flag is set. |
58 TODO: document |
58 |
59 </warning> |
59 The function `cxBufferDestroy()` is to be used when the buffer was initialized with `cxBufferInit()`, |
|
60 and the function `cxBufferFree()` is to be used when the buffer was created with `cxBufferCreate()`. |
|
61 The only difference is, that `cxBufferFree()` additionally deallocates the memory of the `CxBuffer` structure. |
60 |
62 |
61 ## Write |
63 ## Write |
62 |
64 |
63 ```C |
65 ```C |
64 #include <cx/buffer.h> |
66 #include <cx/buffer.h> |
115 |
119 |
116 ```C |
120 ```C |
117 #include <cx/buffer.h> |
121 #include <cx/buffer.h> |
118 |
122 |
119 int cxBufferSeek(CxBuffer *buffer, off_t offset, int whence); |
123 int cxBufferSeek(CxBuffer *buffer, off_t offset, int whence); |
120 |
|
121 bool cxBufferEof(const CxBuffer *buffer); |
|
122 ``` |
124 ``` |
123 |
125 |
124 <warning> |
126 The function `cxBufferSeek()` is a `fseek()`-like function that sets the current position in the buffer |
125 TODO: document |
127 relative to the start (when `whence` is `SEEK_SET`), the current position (when `whence` is `SEEK_CUR`), |
126 </warning> |
128 or end (when `whence` is `SEEK_END`) of the buffer. |
|
129 |
|
130 If the resulting position is negative, or larger than the size (i.e. the first unused byte), |
|
131 this function returns non-zero and sets `errno` to `EOVERFLOW`. |
|
132 |
|
133 > Note that the error behavior of `cxBufferSeek()` is not exactly the same as for POSIX `fseek()`. |
127 |
134 |
128 ## Shift Contents |
135 ## Shift Contents |
129 |
136 |
130 ```C |
137 ```C |
131 #include <cx/buffer.h> |
138 #include <cx/buffer.h> |