aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/writer.c b/src/writer.c
index 09470b1a..fa15a47a 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -155,13 +155,21 @@ free_context(SerdWriter* writer)
return SERD_SUCCESS;
}
-static inline void
-push_context(SerdWriter* writer, const WriteContext new_context)
+static void
+push_context(SerdWriter* const writer,
+ const ContextType type,
+ const SerdNode* const g,
+ const SerdNode* const s,
+ const SerdNode* const p)
{
WriteContext* top = (WriteContext*)serd_stack_push(&writer->anon_stack,
sizeof(WriteContext));
*top = writer->context;
+
+ const WriteContext new_context = {
+ type, serd_node_copy(g), serd_node_copy(s), serd_node_copy(p), false};
+
writer->context = new_context;
}
@@ -868,32 +876,20 @@ serd_writer_write_statement(SerdWriter* writer,
}
if (flags & SERD_LIST_S) {
- const WriteContext ctx = {CTX_LIST,
- serd_node_copy(graph),
- serd_node_copy(subject),
- NULL,
- false};
- push_context(writer, ctx);
+ push_context(writer, CTX_LIST, graph, subject, NULL);
} if (flags & SERD_LIST_O) {
- const WriteContext ctx = {CTX_LIST,
- serd_node_copy(graph),
- serd_node_copy(object),
- NULL,
- false};
- push_context(writer, ctx);
+ push_context(writer, CTX_LIST, graph, object, NULL);
}
if (flags & (SERD_ANON_S | SERD_ANON_O)) {
const bool is_list = flags & (SERD_LIST_S | SERD_LIST_O);
const bool is_subject = flags & SERD_ANON_S;
- const WriteContext ctx = {is_list ? CTX_LIST : CTX_BLANK,
- serd_node_copy(graph),
- serd_node_copy(subject),
- is_subject ? serd_node_copy(predicate) : NULL,
- false};
-
- push_context(writer, ctx);
+ push_context(writer,
+ is_list ? CTX_LIST : CTX_BLANK,
+ graph,
+ subject,
+ is_subject ? predicate : NULL);
} else {
serd_node_set(&writer->context.graph, graph);
serd_node_set(&writer->context.subject, subject);