| 41 | }; |
| 42 | |
| 43 | PN_STRUCT_CLASSDEF(pn_buffer) |
| 44 | |
| 45 | pn_buffer_t *pn_buffer(size_t capacity) |
| 46 | { |
| 47 | pn_buffer_t *buf = (pn_buffer_t *) pni_mem_allocate(PN_CLASSCLASS(pn_buffer), sizeof(pn_buffer_t)); |
| 48 | if (buf != NULL) { |
| 49 | buf->capacity = capacity; |
| 50 | buf->start = 0; |
| 51 | buf->size = 0; |
| 52 | if (capacity > 0) { |
| 53 | buf->bytes = (char *) pni_mem_suballocate(PN_CLASSCLASS(pn_buffer), buf, capacity); |
| 54 | if (buf->bytes == NULL) { |
| 55 | pni_mem_deallocate(PN_CLASSCLASS(pn_buffer), buf); |
| 56 | buf = NULL; |
| 57 | } |
| 58 | } |
| 59 | else { |
| 60 | buf->bytes = NULL; |
| 61 | } |
| 62 | } |
| 63 | return buf; |
| 64 | } |
| 65 | |
| 66 | void pn_buffer_free(pn_buffer_t *buf) |
| 67 | { |
no test coverage detected