diff options
Diffstat (limited to 'source/kit/input_buffer.c')
-rw-r--r-- | source/kit/input_buffer.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/source/kit/input_buffer.c b/source/kit/input_buffer.c index c59031f..2ba3f4c 100644 --- a/source/kit/input_buffer.c +++ b/source/kit/input_buffer.c @@ -13,8 +13,8 @@ typedef struct { static internal_buffer_t *buf_init(kit_is_handle_t upstream, kit_allocator_t alloc) { assert(alloc.allocate != NULL); - internal_buffer_t *const buf = kit_alloc_dispatch( - alloc, KIT_ALLOCATE, sizeof *buf, 0, NULL); + internal_buffer_t *buf = kit_alloc_dispatch(alloc, KIT_ALLOCATE, + sizeof *buf, 0, NULL); if (buf != NULL) { memset(buf, 0, sizeof *buf); @@ -42,7 +42,7 @@ static void buf_acquire(void *p) { static void buf_release(void *p) { assert(p != NULL); - internal_buffer_t *const buf = (internal_buffer_t *) p; + internal_buffer_t *buf = (internal_buffer_t *) p; if (--buf->ref_count == 0) { DA_DESTROY(buf->data); @@ -54,21 +54,20 @@ static void buf_adjust(void *p, ptrdiff_t size) { assert(p != NULL); assert(size >= 0); - internal_buffer_t *const buf = (internal_buffer_t *) p; - ptrdiff_t const offset = buf->data.size; + internal_buffer_t *buf = (internal_buffer_t *) p; + ptrdiff_t offset = buf->data.size; if (offset < size) { DA_RESIZE(buf->data, size); - kit_out_str_t destination = { - .size = size - offset, .values = buf->data.values + offset - }; - ptrdiff_t n = KIT_IS_READ(buf->upstream, destination); + kit_str_t destination = { .size = size - offset, + .values = buf->data.values + offset }; + ptrdiff_t n = KIT_IS_READ(buf->upstream, destination); DA_RESIZE(buf->data, offset + n); } } static ptrdiff_t buf_read(void *p, ptrdiff_t offset, - kit_out_str_t destination) { + kit_str_t destination) { internal_buffer_t *buf = (internal_buffer_t *) p; ptrdiff_t n = destination.size < buf->data.size - offset ? destination.size @@ -105,11 +104,11 @@ kit_ib_handle_t kit_ib_read(kit_ib_handle_t buf, ptrdiff_t size) { if (next.data.size != size) next.status = KIT_ERROR_BAD_ALLOC; - kit_out_str_t destination = { .size = next.data.size, - .values = next.data.values }; - ptrdiff_t const n = buf_read(buf.internal, buf.offset, destination); - next.offset = buf.offset + n; - next.internal = buf.internal; + kit_str_t destination = { .size = next.data.size, + .values = next.data.values }; + ptrdiff_t n = buf_read(buf.internal, buf.offset, destination); + next.offset = buf.offset + n; + next.internal = buf.internal; DA_RESIZE(next.data, n); if (next.data.size != n) @@ -141,10 +140,10 @@ kit_ib_handle_t kit_ib_read_while( if (next.data.size != size + 1) next.status = KIT_ERROR_BAD_ALLOC; - kit_out_str_t destination = { .size = 1, - .values = next.data.values + size }; - ptrdiff_t const n = buf_read(buf.internal, buf.offset + size, - destination); + kit_str_t destination = { .size = 1, + .values = next.data.values + size }; + ptrdiff_t n = buf_read(buf.internal, buf.offset + size, + destination); kit_str_t data = { .size = size + 1, .values = next.data.values }; if (n != 1 || condition == NULL || condition(data) == 0) |