From a29581d3ba664175c459e20e6c86be09707fde6e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 16 Mar 2016 16:21:20 -0400 Subject: Use char* for strings in public API The constant casting just makes user code a mess, for no benefit. --- src/byte_sink.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/byte_sink.h') diff --git a/src/byte_sink.h b/src/byte_sink.h index dc55ba1e..d5222843 100644 --- a/src/byte_sink.h +++ b/src/byte_sink.h @@ -23,13 +23,12 @@ #include "serd/serd.h" #include -#include #include typedef struct SerdByteSinkImpl { SerdSink sink; void* stream; - uint8_t* buf; + char* buf; size_t size; size_t block_size; } SerdByteSink; @@ -37,12 +36,13 @@ typedef struct SerdByteSinkImpl { static inline SerdByteSink serd_byte_sink_new(SerdSink sink, void* stream, size_t block_size) { - SerdByteSink bsink = {sink, stream, NULL, 0, block_size}; - - if (block_size > 1) { - bsink.buf = (uint8_t*)serd_allocate_buffer(block_size); - } - + SerdByteSink bsink; + bsink.sink = sink; + bsink.stream = stream; + bsink.size = 0; + bsink.block_size = block_size; + bsink.buf = + ((block_size > 1) ? (char*)serd_allocate_buffer(block_size) : NULL); return bsink; } @@ -82,7 +82,7 @@ serd_byte_sink_write(const void* buf, size_t len, SerdByteSink* bsink) // Write as much as possible into the remaining buffer space memcpy(bsink->buf + bsink->size, buf, n); bsink->size += n; - buf = (const uint8_t*)buf + n; + buf = (const char*)buf + n; len -= n; // Flush page if buffer is full @@ -91,7 +91,6 @@ serd_byte_sink_write(const void* buf, size_t len, SerdByteSink* bsink) bsink->size = 0; } } - return orig_len; } -- cgit v1.2.1