diff options
Diffstat (limited to 'src/reader.c')
-rw-r--r-- | src/reader.c | 34 |
1 files changed, 7 insertions, 27 deletions
diff --git a/src/reader.c b/src/reader.c index 3b4dfd2b..ae50adab 100644 --- a/src/reader.c +++ b/src/reader.c @@ -69,6 +69,13 @@ push_node_padded(SerdReader* const reader, const char* const str, const size_t length) { + // Push a null byte to ensure the previous node was null terminated + char* terminator = (char*)serd_stack_push(&reader->stack, 1); + if (!terminator) { + return NULL; + } + *terminator = 0; + void* mem = serd_stack_push_aligned( &reader->stack, sizeof(SerdNode) + maxlen + 1, sizeof(SerdNode)); @@ -85,12 +92,6 @@ push_node_padded(SerdReader* const reader, char* buf = (char*)(node + 1); memcpy(buf, str, length + 1); -#ifdef SERD_STACK_CHECK - reader->allocs = (SerdNode**)realloc( - reader->allocs, sizeof(reader->allocs) * (++reader->n_allocs)); - reader->allocs[reader->n_allocs - 1] = - (SerdNode*)((char*)mem - reader->stack.buf); -#endif return node; } @@ -103,21 +104,6 @@ push_node(SerdReader* const reader, return push_node_padded(reader, length, type, str, length); } -SerdNode* -pop_node(SerdReader* const reader, const SerdNode* const node) -{ - if (node && node != reader->rdf_first && node != reader->rdf_rest && - node != reader->rdf_nil) { -#ifdef SERD_STACK_CHECK - SERD_STACK_ASSERT_TOP(reader, node); - --reader->n_allocs; -#endif - char* const top = reader->stack.buf + reader->stack.size; - serd_stack_pop_aligned(&reader->stack, (size_t)(top - (char*)node)); - } - return NULL; -} - SerdStatus emit_statement(SerdReader* const reader, const ReadContext ctx, @@ -204,15 +190,9 @@ serd_reader_free(SerdReader* const reader) return; } - pop_node(reader, reader->rdf_nil); - pop_node(reader, reader->rdf_rest); - pop_node(reader, reader->rdf_first); serd_reader_finish(reader); serd_node_free(reader->default_graph); -#ifdef SERD_STACK_CHECK - free(reader->allocs); -#endif free(reader->stack.buf); free(reader->bprefix); free(reader); |