76 * |
76 * |
77 * The current contents of the buffer will be copied to the new memory and the flag |
77 * The current contents of the buffer will be copied to the new memory and the flag |
78 * will be cleared while the #CX_BUFFER_FREE_CONTENTS flag will be set automatically. |
78 * will be cleared while the #CX_BUFFER_FREE_CONTENTS flag will be set automatically. |
79 */ |
79 */ |
80 #define CX_BUFFER_COPY_ON_WRITE 0x04 |
80 #define CX_BUFFER_COPY_ON_WRITE 0x04 |
|
81 |
|
82 /** |
|
83 * If this flag is enabled, the buffer will copy its contents to a new memory area on reallocation. |
|
84 * |
|
85 * After performing the copy, the flag is automatically cleared. |
|
86 * This flag has no effect on buffers which do not have #CX_BUFFER_AUTO_EXTEND set, which is why |
|
87 * buffers automatically admit the auto-extend flag when initialized with copy-on-extend enabled. |
|
88 */ |
|
89 #define CX_BUFFER_COPY_ON_EXTEND 0x08 |
81 |
90 |
82 /** Structure for the UCX buffer data. */ |
91 /** Structure for the UCX buffer data. */ |
83 typedef struct { |
92 typedef struct { |
84 /** A pointer to the buffer contents. */ |
93 /** A pointer to the buffer contents. */ |
85 union { |
94 union { |
154 * |
163 * |
155 * You may also provide a read-only \p space, in which case |
164 * You may also provide a read-only \p space, in which case |
156 * you will need to cast the pointer, and you should set the |
165 * you will need to cast the pointer, and you should set the |
157 * #CX_BUFFER_COPY_ON_WRITE flag. |
166 * #CX_BUFFER_COPY_ON_WRITE flag. |
158 * |
167 * |
|
168 * When you specify stack memory as \p space and decide to use |
|
169 * the auto-extension feature, you \em must use the |
|
170 * #CX_BUFFER_COPY_ON_EXTEND flag, instead of the |
|
171 * #CX_BUFFER_AUTO_EXTEND flag. |
|
172 * |
159 * \note You may provide \c NULL as argument for \p space. |
173 * \note You may provide \c NULL as argument for \p space. |
160 * Then this function will allocate the space and enforce |
174 * Then this function will allocate the space and enforce |
161 * the #CX_BUFFER_FREE_CONTENTS flag. In that case, specifying |
175 * the #CX_BUFFER_FREE_CONTENTS flag. In that case, specifying |
162 * copy-on-write should be avoided, because the allocated |
176 * copy-on-write should be avoided, because the allocated |
163 * space will be leaking after the copy-on-write operation. |
177 * space will be leaking after the copy-on-write operation. |
211 * Allocates and initializes a fresh buffer. |
225 * Allocates and initializes a fresh buffer. |
212 * |
226 * |
213 * You may also provide a read-only \p space, in which case |
227 * You may also provide a read-only \p space, in which case |
214 * you will need to cast the pointer, and you should set the |
228 * you will need to cast the pointer, and you should set the |
215 * #CX_BUFFER_COPY_ON_WRITE flag. |
229 * #CX_BUFFER_COPY_ON_WRITE flag. |
|
230 * When you specify stack memory as \p space and decide to use |
|
231 * the auto-extension feature, you \em must use the |
|
232 * #CX_BUFFER_COPY_ON_EXTEND flag, instead of the |
|
233 * #CX_BUFFER_AUTO_EXTEND flag. |
216 * |
234 * |
217 * \note You may provide \c NULL as argument for \p space. |
235 * \note You may provide \c NULL as argument for \p space. |
218 * Then this function will allocate the space and enforce |
236 * Then this function will allocate the space and enforce |
219 * the #CX_BUFFER_FREE_CONTENTS flag. |
237 * the #CX_BUFFER_FREE_CONTENTS flag. |
220 * |
238 * |