diff options
-rw-r--r-- | src/sord.c | 7 | ||||
-rw-r--r-- | src/sord_internal.h | 3 | ||||
-rw-r--r-- | src/syntax.c | 13 |
3 files changed, 17 insertions, 6 deletions
@@ -797,7 +797,7 @@ sord_new_literal_node(SordWorld world, SordNode datatype, const char* lang, uint8_t lang_len) { SordNode node = sord_new_node(SORD_LITERAL, str, str_len + 1); - node->datatype = datatype; + node->datatype = sord_node_copy(datatype); node->lang = sord_intern_lang(world, lang); return node; } @@ -945,6 +945,7 @@ sord_node_free(SordWorld world, SordNode node) fprintf(stderr, "Failed to remove literal from hash.\n"); return; } + sord_node_free(world, node->datatype); } else { if (!g_hash_table_remove(world->names, node->buf)) { fprintf(stderr, "Failed to remove resource from hash.\n"); @@ -959,7 +960,9 @@ sord_node_free(SordWorld world, SordNode node) SordNode sord_node_copy(SordNode node) { - ++node->refs; + if (node) { + ++node->refs; + } return node; } diff --git a/src/sord_internal.h b/src/sord_internal.h index 7d62e54..8f6f9e8 100644 --- a/src/sord_internal.h +++ b/src/sord_internal.h @@ -34,4 +34,7 @@ struct _SordNode { SordNodeType type; ///< SordNodeType }; +const char* +sord_intern_lang(SordWorld world, const char* lang); + #endif /* SORD_SORD_INTERNAL_H_ */ diff --git a/src/syntax.c b/src/syntax.c index 5d3653e..8a31a28 100644 --- a/src/syntax.c +++ b/src/syntax.c @@ -67,15 +67,20 @@ static inline SordNode sord_node_from_serd_node(ReadState* state, const SerdNode* sn, const SerdNode* datatype, const SerdNode* lang) { + SordNode datatype_node = NULL; + SordNode ret = NULL; switch (sn->type) { case SERD_NOTHING: return NULL; case SERD_LITERAL: - return sord_new_literal( + datatype_node = sord_node_from_serd_node(state, datatype, NULL, NULL), + ret = sord_new_literal( state->world, - sord_node_from_serd_node(state, datatype, NULL, NULL), + datatype_node, sn->buf, - g_intern_string((const char*)lang->buf)); + sord_intern_lang(state->world, (const char*)lang->buf)); + sord_node_free(state->world, datatype_node); + return ret; case SERD_URI: { SerdURI base_uri; serd_read_state_get_base_uri(state->read_state, &base_uri); @@ -165,7 +170,7 @@ event_statement(void* handle, sord_node_free(state->world, tup[0]); sord_node_free(state->world, tup[1]); sord_node_free(state->world, tup[2]); - // FIXME: sord_node_free(state->world, tup[3]); + sord_node_free(state->world, tup[3]); return true; } |