docs/Writerside/topics/buffer.h.md

changeset 1259
7bc999fe285d
parent 1256
b9a940779877
child 1260
56a019cdb055
equal deleted inserted replaced
1258:a12e102ff67f 1259:7bc999fe285d
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>
89 91
90 size_t cxBufferRead(void *ptr, size_t size, size_t nitems, 92 size_t cxBufferRead(void *ptr, size_t size, size_t nitems,
91 CxBuffer *buffer); 93 CxBuffer *buffer);
92 94
93 int cxBufferGet(CxBuffer *buffer); 95 int cxBufferGet(CxBuffer *buffer);
96
97 bool cxBufferEof(const CxBuffer *buffer);
94 ``` 98 ```
95 99
96 <warning> 100 <warning>
97 TODO: document 101 TODO: document
98 </warning> 102 </warning>
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>

mercurial