summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sord/sord.h3
-rw-r--r--sord/sordmm.hpp10
-rw-r--r--src/sord.c12
3 files changed, 13 insertions, 12 deletions
diff --git a/sord/sord.h b/sord/sord.h
index 04ea676..2269d13 100644
--- a/sord/sord.h
+++ b/sord/sord.h
@@ -401,10 +401,11 @@ sord_search(SordModel* model,
Search for a single node that matches a pattern.
Exactly one of @p s, @p p, @p o must be NULL.
This function is mainly useful for predicates that only have one value.
+ The returned node must be freed using sord_node_free.
@return the first matching node, or NULL if no matches are found.
*/
SORD_API
-const SordNode*
+SordNode*
sord_get(SordModel* model,
const SordNode* s,
const SordNode* p,
diff --git a/sord/sordmm.hpp b/sord/sordmm.hpp
index 4e6585f..b98afc7 100644
--- a/sord/sordmm.hpp
+++ b/sord/sordmm.hpp
@@ -640,11 +640,11 @@ Model::get(const Node& subject,
const Node& predicate,
const Node& object)
{
- return Node(_world, sord_get(_c_obj,
- subject.c_obj(),
- predicate.c_obj(),
- object.c_obj(),
- NULL));
+ SordNode* c_node = sord_get(
+ _c_obj, subject.c_obj(), predicate.c_obj(), object.c_obj(), NULL);
+ Node node(_world, c_node);
+ sord_node_free(_world.c_obj(), c_node);
+ return node;
}
} // namespace Sord
diff --git a/src/sord.c b/src/sord.c
index 5006212..e3623d7 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -844,7 +844,7 @@ sord_search(SordModel* model,
return sord_find(model, pat);
}
-const SordNode*
+SordNode*
sord_get(SordModel* model,
const SordNode* s,
const SordNode* p,
@@ -855,14 +855,14 @@ sord_get(SordModel* model,
return NULL;
}
- SordIter* i = sord_search(model, s, p, o, g);
- const SordNode* ret = NULL;
+ SordIter* i = sord_search(model, s, p, o, g);
+ SordNode* ret = NULL;
if (!s) {
- ret = sord_iter_get_node(i, SORD_SUBJECT);
+ ret = sord_node_copy(sord_iter_get_node(i, SORD_SUBJECT));
} else if (!p) {
- ret = sord_iter_get_node(i, SORD_PREDICATE);
+ ret = sord_node_copy(sord_iter_get_node(i, SORD_PREDICATE));
} else if (!o) {
- ret = sord_iter_get_node(i, SORD_OBJECT);
+ ret = sord_node_copy(sord_iter_get_node(i, SORD_OBJECT));
}
sord_iter_free(i);