diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/reader.c | 4 | ||||
-rw-r--r-- | src/serdi.c | 5 | ||||
-rw-r--r-- | src/world.c | 19 | ||||
-rw-r--r-- | src/world.h | 1 |
4 files changed, 25 insertions, 4 deletions
diff --git a/src/reader.c b/src/reader.c index 61da89ff..4702131e 100644 --- a/src/reader.c +++ b/src/reader.c @@ -146,9 +146,9 @@ serd_reader_read_document(SerdReader* const reader) SerdReader* serd_reader_new(SerdWorld* const world, const SerdSyntax syntax, - const SerdSink* const sink, - const size_t stack_size) + const SerdSink* const sink) { + const size_t stack_size = world->limits.reader_stack_size; if (stack_size < 3 * sizeof(SerdNode) + 192 + serd_node_align) { return NULL; } diff --git a/src/serdi.c b/src/serdi.c index 0610069d..105bda46 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -245,8 +245,11 @@ main(int argc, char** argv) SerdWriter* const writer = serd_writer_new( world, output_syntax, writer_flags, env, (SerdWriteFunc)fwrite, out_fd); + const SerdLimits limits = {stack_size}; + serd_world_set_limits(world, limits); + SerdReader* const reader = - serd_reader_new(world, input_syntax, serd_writer_sink(writer), stack_size); + serd_reader_new(world, input_syntax, serd_writer_sink(writer)); serd_reader_set_strict(reader, !lax); if (quiet) { diff --git a/src/world.c b/src/world.c index 21cdffab..7fb5eea2 100644 --- a/src/world.c +++ b/src/world.c @@ -16,6 +16,7 @@ # include <fcntl.h> #endif +#include <assert.h> #include <errno.h> #include <stdarg.h> #include <stdio.h> @@ -102,7 +103,8 @@ serd_world_new(void) return NULL; } - world->blank_node = blank_node; + world->limits.reader_stack_size = 1048576U; + world->blank_node = blank_node; return world; } @@ -116,6 +118,21 @@ serd_world_free(SerdWorld* const world) } } +SerdLimits +serd_world_limits(const SerdWorld* const world) +{ + assert(world); + return world->limits; +} + +SerdStatus +serd_world_set_limits(SerdWorld* const world, const SerdLimits limits) +{ + assert(world); + world->limits = limits; + return SERD_SUCCESS; +} + const SerdNode* serd_world_get_blank(SerdWorld* const world) { diff --git a/src/world.h b/src/world.h index b330d4e4..96252a7a 100644 --- a/src/world.h +++ b/src/world.h @@ -13,6 +13,7 @@ #include <stdio.h> struct SerdWorldImpl { + SerdLimits limits; SerdErrorFunc error_func; void* error_handle; uint32_t next_blank_id; |