aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-05-12 20:39:23 +0200
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commit95f7334bbc02f3e75b33b9914eee58c69f1588bd (patch)
treebed06e929f286d099181d5e2e76ecf508df0add9 /src/writer.c
parent4f4408029cd8cefc1804d75a03f5c3f0ee7922fa (diff)
downloadserd-95f7334bbc02f3e75b33b9914eee58c69f1588bd.tar.gz
serd-95f7334bbc02f3e75b33b9914eee58c69f1588bd.tar.bz2
serd-95f7334bbc02f3e75b33b9914eee58c69f1588bd.zip
Use a fixed-size reader stack
This improves performance, and makes the reader more suitable for embedded or network-facing applications, at the cost of requiring the user to specify a maximum stack size.
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/writer.c b/src/writer.c
index 9d7a6790..827f7264 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -804,6 +804,10 @@ serd_writer_write_statement(SerdWriter* writer,
if (flags & (SERD_ANON_S_BEGIN|SERD_ANON_O_BEGIN)) {
WriteContext* ctx = (WriteContext*)serd_stack_push(
&writer->anon_stack, sizeof(WriteContext));
+ if (!ctx) {
+ return SERD_ERR_OVERFLOW;
+ }
+
*ctx = writer->context;
WriteContext new_context = {
serd_node_copy(graph), serd_node_copy(subject), NULL };
@@ -876,7 +880,7 @@ serd_writer_new(SerdWorld* world,
writer->env = env;
writer->root_node = NULL;
writer->root_uri = SERD_URI_NULL;
- writer->anon_stack = serd_stack_new(4 * sizeof(WriteContext));
+ writer->anon_stack = serd_stack_new(SERD_PAGE_SIZE);
writer->context = context;
writer->list_subj = NULL;
writer->empty = true;