aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/serdi.c12
-rw-r--r--src/writer.c14
2 files changed, 13 insertions, 13 deletions
diff --git a/src/serdi.c b/src/serdi.c
index 13438725..6259a6bf 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -189,15 +189,17 @@ main(int argc, char** argv)
SerdWorld* world = serd_world_new();
SerdEnv* env = serd_env_new(base);
- const SerdStyleFlags output_style = ((ascii ? SERD_STYLE_ASCII : 0) |
- (bulk_write ? SERD_STYLE_BULK : 0));
+ const SerdStyleFlags output_style = (ascii ? SERD_STYLE_ASCII : 0);
+
+ SerdByteSink* byte_sink = serd_byte_sink_new(
+ (SerdWriteFunc)fwrite, out_fd, bulk_write ? 4096 : 1);
SerdWriter* writer = serd_writer_new(world,
output_syntax,
output_style,
env,
- (SerdWriteFunc)fwrite,
- out_fd);
+ (SerdWriteFunc)serd_byte_sink_write,
+ byte_sink);
SerdReader* reader = serd_reader_new(
world, input_syntax, serd_writer_get_sink(writer), stack_size);
@@ -238,8 +240,8 @@ main(int argc, char** argv)
serd_reader_finish(reader);
serd_reader_free(reader);
- serd_writer_finish(writer);
serd_writer_free(writer);
+ serd_byte_sink_free(byte_sink);
serd_env_free(env);
serd_node_free(base);
serd_world_free(world);
diff --git a/src/writer.c b/src/writer.c
index b1f68e59..3c782ae7 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -14,7 +14,6 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#include "byte_sink.h"
#include "env.h"
#include "node.h"
#include "serd_internal.h"
@@ -94,7 +93,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 +159,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
@@ -853,7 +853,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;
@@ -865,7 +864,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;
@@ -877,11 +876,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;
@@ -971,7 +970,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);
}