diff options
author | David Robillard <d@drobilla.net> | 2018-07-13 21:04:54 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-12-31 11:37:48 -0500 |
commit | 8e5dbd1d5b62f66888dbf74929240da0b7ab465b (patch) | |
tree | 51183805ec41f5acb2c07ec17a64d189687c389a /src/writer.c | |
parent | 87a1b30968d422831615ffb2fce33603a3e24e84 (diff) | |
download | serd-8e5dbd1d5b62f66888dbf74929240da0b7ab465b.tar.gz serd-8e5dbd1d5b62f66888dbf74929240da0b7ab465b.tar.bz2 serd-8e5dbd1d5b62f66888dbf74929240da0b7ab465b.zip |
Separate ByteSink from Writer
Diffstat (limited to 'src/writer.c')
-rw-r--r-- | src/writer.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/writer.c b/src/writer.c index a245f860..014213e1 100644 --- a/src/writer.c +++ b/src/writer.c @@ -94,7 +94,8 @@ struct SerdWriterImpl { SerdNode* root_node; SerdURI root_uri; SerdStack anon_stack; - SerdByteSink* byte_sink; + SerdWriteFunc write_func; + void* stream; SerdErrorSink error_sink; void* error_handle; WriteContext context; @@ -159,7 +160,7 @@ ctx(SerdWriter* writer, const SerdField field) static inline size_t sink(const void* buf, size_t len, SerdWriter* writer) { - return serd_byte_sink_write(buf, 1, len, writer->byte_sink); + return writer->write_func(buf, 1, len, writer->stream); } // Write a single character, as an escape for single byte characters @@ -854,7 +855,6 @@ serd_writer_finish(SerdWriter* writer) if (ctx(writer, SERD_GRAPH)) { write_sep(writer, SEP_GRAPH_END); } - serd_byte_sink_flush(writer->byte_sink); free_context(writer); writer->indent = 0; writer->context = WRITE_CONTEXT_NULL; @@ -866,7 +866,7 @@ serd_writer_new(SerdWorld* world, SerdSyntax syntax, SerdStyleFlags style, SerdEnv* env, - SerdWriteFunc ssink, + SerdWriteFunc write_func, void* stream) { const WriteContext context = WRITE_CONTEXT_NULL; @@ -878,11 +878,11 @@ serd_writer_new(SerdWorld* world, writer->root_node = NULL; writer->root_uri = SERD_URI_NULL; writer->anon_stack = serd_stack_new(SERD_PAGE_SIZE); + writer->write_func = write_func; + writer->stream = stream; writer->context = context; writer->list_subj = NULL; writer->empty = true; - writer->byte_sink = serd_byte_sink_new( - ssink, stream, (style & SERD_STYLE_BULK) ? SERD_PAGE_SIZE : 1); writer->iface.handle = writer; writer->iface.base = (SerdBaseSink)serd_writer_set_base_uri; @@ -972,7 +972,6 @@ serd_writer_free(SerdWriter* writer) serd_writer_finish(writer); serd_stack_free(&writer->anon_stack); free(writer->bprefix); - serd_byte_sink_free(writer->byte_sink); serd_node_free(writer->root_node); free(writer); } |