diff options
author | David Robillard <d@drobilla.net> | 2018-07-13 21:04:54 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:05 -0500 |
commit | ab699377c12033a5b4d562b37f4a56fbe4505a21 (patch) | |
tree | 646d35a2c82d80e0287c4e72bca2e646a1adad31 /src/writer.c | |
parent | eb0700d313915e2b291bdb91271c2e7ec3d9ba84 (diff) | |
download | serd-ab699377c12033a5b4d562b37f4a56fbe4505a21.tar.gz serd-ab699377c12033a5b4d562b37f4a56fbe4505a21.tar.bz2 serd-ab699377c12033a5b4d562b37f4a56fbe4505a21.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 a522e0fb..0fabb7af 100644 --- a/src/writer.c +++ b/src/writer.c @@ -92,7 +92,8 @@ struct SerdWriterImpl { SerdNode* root_node; SerdURIView root_uri; SerdStack anon_stack; - SerdByteSink* byte_sink; + SerdWriteFunc write_func; + void* stream; SerdErrorFunc error_func; void* error_handle; WriteContext context; @@ -156,7 +157,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 @@ -964,7 +965,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; @@ -976,7 +976,7 @@ serd_writer_new(SerdWorld* world, SerdSyntax syntax, SerdWriterFlags flags, SerdEnv* env, - SerdWriteFunc ssink, + SerdWriteFunc write_func, void* stream) { const WriteContext context = WRITE_CONTEXT_NULL; @@ -989,11 +989,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, (flags & SERD_WRITE_BULK) ? SERD_PAGE_SIZE : 1); writer->iface.handle = writer; writer->iface.on_event = (SerdEventFunc)serd_writer_on_event; @@ -1091,7 +1091,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); } |