src/cx/buffer.h

changeset 683
aa0d09f2d81c
parent 673
60fb6aec157d
child 757
49ceea78fce7
equal deleted inserted replaced
682:34120a385fc8 683:aa0d09f2d81c
162 CxAllocator const *allocator, 162 CxAllocator const *allocator,
163 int flags 163 int flags
164 ); 164 );
165 165
166 /** 166 /**
167 * Allocates and initializes a fresh buffer.
168 *
169 * \note You may provide \c NULL as argument for \p space.
170 * Then this function will allocate the space and enforce
171 * the #CX_BUFFER_FREE_CONTENTS flag.
172 *
173 * @param space pointer to the memory area, or \c NULL to allocate
174 * new memory
175 * @param capacity the capacity of the buffer
176 * @param allocator the allocator to use for allocating the structure and the automatic
177 * memory management within the buffer. If \c NULL, the default heap allocator will be used.
178 * @param flags buffer features (see cx_buffer_s.flags)
179 * @return a pointer to the buffer on success, \c NULL if a required allocation failed
180 */
181 CxBuffer *cxBufferCreate(
182 void *space,
183 size_t capacity,
184 CxAllocator const *allocator,
185 int flags
186 );
187
188 /**
167 * Destroys the buffer contents. 189 * Destroys the buffer contents.
168 * 190 *
169 * Has no effect if the #CX_BUFFER_FREE_CONTENTS feature is not enabled. 191 * Has no effect if the #CX_BUFFER_FREE_CONTENTS feature is not enabled.
192 * If you want to free the memory of the entire buffer, use cxBufferFree().
170 * 193 *
171 * @param buffer the buffer which contents shall be destroyed 194 * @param buffer the buffer which contents shall be destroyed
195 * @see cxBufferInit()
172 */ 196 */
173 __attribute__((__nonnull__)) 197 __attribute__((__nonnull__))
174 void cxBufferDestroy(CxBuffer *buffer); 198 void cxBufferDestroy(CxBuffer *buffer);
199
200 /**
201 * Deallocates the buffer.
202 *
203 * If the #CX_BUFFER_FREE_CONTENTS feature is enabled, this function also destroys
204 * the contents. If you \em only want to destroy the contents, use cxBufferDestroy().
205 *
206 * @param buffer the buffer to deallocate
207 * @see cxBufferCreate()
208 */
209 __attribute__((__nonnull__))
210 void cxBufferFree(CxBuffer *buffer);
175 211
176 /** 212 /**
177 * Shifts the contents of the buffer by the given offset. 213 * Shifts the contents of the buffer by the given offset.
178 * 214 *
179 * If the offset is positive, the contents are shifted to the right. 215 * If the offset is positive, the contents are shifted to the right.

mercurial