1029:c065d196a2c8 | 1030:06091e067bee |
---|---|
81 | 81 |
82 void cxBufferDestroy(CxBuffer *buffer) { | 82 void cxBufferDestroy(CxBuffer *buffer) { |
83 if (buffer->flags & CX_BUFFER_FREE_CONTENTS) { | 83 if (buffer->flags & CX_BUFFER_FREE_CONTENTS) { |
84 cxFree(buffer->allocator, buffer->bytes); | 84 cxFree(buffer->allocator, buffer->bytes); |
85 } | 85 } |
86 memset(buffer, 0, sizeof(CxBuffer)); | |
86 } | 87 } |
87 | 88 |
88 CxBuffer *cxBufferCreate( | 89 CxBuffer *cxBufferCreate( |
89 void *space, | 90 void *space, |
90 size_t capacity, | 91 size_t capacity, |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
107 void cxBufferFree(CxBuffer *buffer) { | 108 void cxBufferFree(CxBuffer *buffer) { |
108 if (buffer == NULL) return; | 109 if (buffer == NULL) return; |
110 const CxAllocator *allocator = buffer->allocator; | |
109 cxBufferDestroy(buffer); | 111 cxBufferDestroy(buffer); |
110 cxFree(buffer->allocator, buffer); | 112 cxFree(allocator, buffer); |
111 } | 113 } |
112 | 114 |
113 int cxBufferSeek( | 115 int cxBufferSeek( |
114 CxBuffer *buffer, | 116 CxBuffer *buffer, |
115 off_t offset, | 117 off_t offset, |
329 return nitems_out; | 331 return nitems_out; |
330 } | 332 } |
331 | 333 |
332 } | 334 } |
333 | 335 |
336 size_t cxBufferAppend( | |
337 const void *ptr, | |
338 size_t size, | |
339 size_t nitems, | |
340 CxBuffer *buffer | |
341 ) { | |
342 size_t pos = buffer->pos; | |
343 buffer->pos = buffer->size; | |
344 size_t written = cxBufferWrite(ptr, size, nitems, buffer); | |
345 buffer->pos = pos; | |
346 return written; | |
347 } | |
348 | |
334 int cxBufferPut( | 349 int cxBufferPut( |
335 CxBuffer *buffer, | 350 CxBuffer *buffer, |
336 int c | 351 int c |
337 ) { | 352 ) { |
338 c &= 0xFF; | 353 c &= 0xFF; |