From f046eb982627f344fc0eeff6be82028318862e67 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 15 Mar 2016 23:21:34 -0400 Subject: Use SerdBuffer for mutable buffers This avoids const violations from abusing SerdChunk as a mutable buffer for string sinks. --- src/writer.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/writer.c') 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; } -- cgit v1.2.1