diff options
Diffstat (limited to 'src/byte_sink.h')
-rw-r--r-- | src/byte_sink.h | 19 |
1 files changed, 9 insertions, 10 deletions
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 <stddef.h> -#include <stdint.h> #include <string.h> 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; } |