aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-05-08 15:27:32 -0400
committerDavid Robillard <d@drobilla.net>2022-06-10 10:36:59 -0400
commitf6437f606bd85dbc6d7581146955f85902230ca0 (patch)
tree29526f43272a8c13455379f4f34b0580af0aa729 /src
parent272d7081257dc6d50c06b1b62e8c4baa5bf3b4b2 (diff)
downloadserd-f6437f606bd85dbc6d7581146955f85902230ca0.tar.gz
serd-f6437f606bd85dbc6d7581146955f85902230ca0.tar.bz2
serd-f6437f606bd85dbc6d7581146955f85902230ca0.zip
Fix memory consumption when reading documents
Diffstat (limited to 'src')
-rw-r--r--src/n3.c14
-rw-r--r--src/serd_config.h4
2 files changed, 15 insertions, 3 deletions
diff --git a/src/n3.c b/src/n3.c
index 33828258..60d975c2 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -1572,7 +1572,7 @@ read_wrappedGraph(SerdReader* const reader, ReadContext* const ctx)
reader, SERD_ERR_BAD_SYNTAX, "missing predicate object list\n");
}
- pop_node(reader, ctx->subject);
+ ctx->subject = pop_node(reader, ctx->subject);
read_ws_star(reader);
if (peek_byte(reader) == '.') {
eat_byte_safe(reader, '.');
@@ -1606,6 +1606,10 @@ tokcmp(SerdReader* const reader,
SerdStatus
read_n3_statement(SerdReader* const reader)
{
+#ifndef NDEBUG
+ const size_t orig_stack_size = reader->stack.size;
+#endif
+
SerdStatementFlags flags = 0;
ReadContext ctx = {0, 0, 0, 0, 0, 0, &flags};
bool ate_dot = false;
@@ -1646,6 +1650,7 @@ read_n3_statement(SerdReader* const reader)
} else if (!tokcmp(reader, ctx.subject, "prefix", 6)) {
st = read_prefixID(reader, true, false);
} else if (!tokcmp(reader, ctx.subject, "graph", 5)) {
+ ctx.subject = pop_node(reader, ctx.subject);
read_ws_star(reader);
TRY(st, read_labelOrSubject(reader, &ctx.graph));
read_ws_star(reader);
@@ -1678,8 +1683,15 @@ read_n3_statement(SerdReader* const reader)
st = (eat_byte_check(reader, '.') == '.') ? SERD_SUCCESS
: SERD_ERR_BAD_SYNTAX;
}
+
+ ctx.subject = pop_node(reader, ctx.subject);
break;
}
+
+#ifndef NDEBUG
+ assert(reader->stack.size == orig_stack_size);
+#endif
+
return st;
}
diff --git a/src/serd_config.h b/src/serd_config.h
index 17c56929..1af3f423 100644
--- a/src/serd_config.h
+++ b/src/serd_config.h
@@ -1,5 +1,5 @@
/*
- Copyright 2021 David Robillard <d@drobilla.net>
+ Copyright 2021-2022 David Robillard <d@drobilla.net>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
@@ -29,7 +29,7 @@
#define SERD_CONFIG_H
// Define version unconditionally so a warning will catch a mismatch
-#define SERD_VERSION "0.30.12"
+#define SERD_VERSION "0.30.13"
#if !defined(SERD_NO_DEFAULT_CONFIG)