src/cx/buffer.h

changeset 890
54565fd74e74
parent 761
61d5197d612b
equal deleted inserted replaced
889:f549fd9fbd8f 890:54565fd74e74
80 * Data is interpreted as binary. 80 * Data is interpreted as binary.
81 */ 81 */
82 unsigned char *bytes; 82 unsigned char *bytes;
83 }; 83 };
84 /** The allocator to use for automatic memory management. */ 84 /** The allocator to use for automatic memory management. */
85 CxAllocator const *allocator; 85 const CxAllocator *allocator;
86 /** Current position of the buffer. */ 86 /** Current position of the buffer. */
87 size_t pos; 87 size_t pos;
88 /** Current capacity (i.e. maximum size) of the buffer. */ 88 /** Current capacity (i.e. maximum size) of the buffer. */
89 size_t capacity; 89 size_t capacity;
90 /** Current size of the buffer content. */ 90 /** Current size of the buffer content. */
156 __attribute__((__nonnull__(1))) 156 __attribute__((__nonnull__(1)))
157 int cxBufferInit( 157 int cxBufferInit(
158 CxBuffer *buffer, 158 CxBuffer *buffer,
159 void *space, 159 void *space,
160 size_t capacity, 160 size_t capacity,
161 CxAllocator const *allocator, 161 const CxAllocator *allocator,
162 int flags 162 int flags
163 ); 163 );
164 164
165 /** 165 /**
166 * Allocates and initializes a fresh buffer. 166 * Allocates and initializes a fresh buffer.
178 * @return a pointer to the buffer on success, \c NULL if a required allocation failed 178 * @return a pointer to the buffer on success, \c NULL if a required allocation failed
179 */ 179 */
180 CxBuffer *cxBufferCreate( 180 CxBuffer *cxBufferCreate(
181 void *space, 181 void *space,
182 size_t capacity, 182 size_t capacity,
183 CxAllocator const *allocator, 183 const CxAllocator *allocator,
184 int flags 184 int flags
185 ); 185 );
186 186
187 /** 187 /**
188 * Destroys the buffer contents. 188 * Destroys the buffer contents.
337 * @param buffer the buffer to test 337 * @param buffer the buffer to test
338 * @return non-zero, if the current buffer position has exceeded the last 338 * @return non-zero, if the current buffer position has exceeded the last
339 * byte of the buffer's contents. 339 * byte of the buffer's contents.
340 */ 340 */
341 __attribute__((__nonnull__)) 341 __attribute__((__nonnull__))
342 int cxBufferEof(CxBuffer const *buffer); 342 int cxBufferEof(const CxBuffer *buffer);
343 343
344 344
345 /** 345 /**
346 * Ensures that the buffer has a minimum capacity. 346 * Ensures that the buffer has a minimum capacity.
347 * 347 *
383 * @param buffer the CxBuffer to write to 383 * @param buffer the CxBuffer to write to
384 * @return the total count of elements written 384 * @return the total count of elements written
385 */ 385 */
386 __attribute__((__nonnull__)) 386 __attribute__((__nonnull__))
387 size_t cxBufferWrite( 387 size_t cxBufferWrite(
388 void const *ptr, 388 const void *ptr,
389 size_t size, 389 size_t size,
390 size_t nitems, 390 size_t nitems,
391 CxBuffer *buffer 391 CxBuffer *buffer
392 ); 392 );
393 393

mercurial