src/buffer.c

changeset 989
8aa57a7fecc4
parent 985
68754c7de906
equal deleted inserted replaced
988:15b3ca7ee33f 989:8aa57a7fecc4
36 void *space, 36 void *space,
37 size_t capacity, 37 size_t capacity,
38 const CxAllocator *allocator, 38 const CxAllocator *allocator,
39 int flags 39 int flags
40 ) { 40 ) {
41 if (allocator == NULL) allocator = cxDefaultAllocator; 41 if (allocator == NULL) {
42 allocator = cxDefaultAllocator;
43 }
42 buffer->allocator = allocator; 44 buffer->allocator = allocator;
43 buffer->flags = flags; 45 buffer->flags = flags;
44 if (!space) { 46 if (!space) {
45 buffer->bytes = cxMalloc(allocator, capacity); 47 buffer->bytes = cxMalloc(allocator, capacity);
46 if (buffer->bytes == NULL) { 48 if (buffer->bytes == NULL) {
73 void *space, 75 void *space,
74 size_t capacity, 76 size_t capacity,
75 const CxAllocator *allocator, 77 const CxAllocator *allocator,
76 int flags 78 int flags
77 ) { 79 ) {
80 if (allocator == NULL) {
81 allocator = cxDefaultAllocator;
82 }
78 CxBuffer *buf = cxMalloc(allocator, sizeof(CxBuffer)); 83 CxBuffer *buf = cxMalloc(allocator, sizeof(CxBuffer));
79 if (buf == NULL) return NULL; 84 if (buf == NULL) return NULL;
80 if (0 == cxBufferInit(buf, space, capacity, allocator, flags)) { 85 if (0 == cxBufferInit(buf, space, capacity, allocator, flags)) {
81 return buf; 86 return buf;
82 } else { 87 } else {

mercurial