diff options
author | David Robillard <d@drobilla.net> | 2016-03-16 16:21:20 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-07 15:32:23 -0500 |
commit | a29581d3ba664175c459e20e6c86be09707fde6e (patch) | |
tree | d11253ca88b09d7a768740b00332a4d780e3852d /src/byte_sink.h | |
parent | 6e856d3e7a9c3162b9af350d5cec8a3f6bb94ee2 (diff) | |
download | serd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.gz serd-a29581d3ba664175c459e20e6c86be09707fde6e.tar.bz2 serd-a29581d3ba664175c459e20e6c86be09707fde6e.zip |
Use char* for strings in public API
The constant casting just makes user code a mess, for no benefit.
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; } |