diff options
author | David Robillard <d@drobilla.net> | 2016-03-15 23:21:34 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-25 09:21:03 +0100 |
commit | f046eb982627f344fc0eeff6be82028318862e67 (patch) | |
tree | a8216165d6e74ff5650e4cdd5a2a44b05b611f63 /src/writer.c | |
parent | fc6ef04d8b94909523708c1bdbb9ea8f42063662 (diff) | |
download | serd-f046eb982627f344fc0eeff6be82028318862e67.tar.gz serd-f046eb982627f344fc0eeff6be82028318862e67.tar.bz2 serd-f046eb982627f344fc0eeff6be82028318862e67.zip |
Use SerdBuffer for mutable buffers
This avoids const violations from abusing SerdChunk as a mutable buffer
for string sinks.
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/writer.c b/src/writer.c index 69a00d82..00e5bf57 100644 --- a/src/writer.c +++ b/src/writer.c @@ -977,18 +977,18 @@ serd_file_sink(const void* buf, size_t len, void* stream) } size_t -serd_chunk_sink(const void* buf, size_t len, void* stream) +serd_buffer_sink(const void* buf, size_t len, void* stream) { - SerdChunk* chunk = (SerdChunk*)stream; - chunk->buf = (uint8_t*)realloc((uint8_t*)chunk->buf, chunk->len + len); - memcpy((uint8_t*)chunk->buf + chunk->len, buf, len); - chunk->len += len; + SerdBuffer* buffer = (SerdBuffer*)stream; + buffer->buf = (char*)realloc(buffer->buf, buffer->len + len); + memcpy((uint8_t*)buffer->buf + buffer->len, buf, len); + buffer->len += len; return len; } uint8_t* -serd_chunk_sink_finish(SerdChunk* stream) +serd_buffer_sink_finish(SerdBuffer* stream) { - serd_chunk_sink("", 1, stream); + serd_buffer_sink("", 1, stream); return (uint8_t*)stream->buf; } |