|
@@ -366,12 +366,11 @@ LSUP_graph_copy_contents (const LSUP_Graph *src, LSUP_Graph *dest)
|
|
|
|
|
|
LSUP_GraphIterator *it = LSUP_graph_lookup (src, NULL, NULL, NULL, NULL);
|
|
|
|
|
|
- LSUP_Triple spo;
|
|
|
-
|
|
|
+ LSUP_Triple *spo = NULL;
|
|
|
LSUP_GraphIterator *add_it = LSUP_graph_add_init (dest);
|
|
|
while (LSUP_graph_iter_next (it, &spo) != LSUP_END) {
|
|
|
- LSUP_rc add_rc = LSUP_graph_add_iter (add_it, &spo);
|
|
|
- LSUP_triple_done (&spo);
|
|
|
+ LSUP_rc add_rc = LSUP_graph_add_iter (add_it, spo);
|
|
|
+ LSUP_triple_free (spo);
|
|
|
if (LIKELY (add_rc == LSUP_OK)) rc = LSUP_OK;
|
|
|
else if (add_rc < 0) {
|
|
|
rc = add_rc;
|
|
@@ -421,18 +420,20 @@ LSUP_graph_lookup (
|
|
|
|
|
|
|
|
|
LSUP_rc
|
|
|
-LSUP_graph_iter_next (LSUP_GraphIterator *it, LSUP_Triple *spo)
|
|
|
+LSUP_graph_iter_next (LSUP_GraphIterator *it, LSUP_Triple **spo_p)
|
|
|
{
|
|
|
LSUP_rc rc = graph_iter_next_buffer (it);
|
|
|
PRCCK (rc);
|
|
|
if (rc != LSUP_OK) return rc;
|
|
|
|
|
|
- spo->s = LSUP_term_new_from_buffer (it->sspo->s);
|
|
|
- if (!spo->s) return LSUP_ERROR;
|
|
|
- spo->p = LSUP_term_new_from_buffer (it->sspo->p);
|
|
|
- if (!spo->p) return LSUP_ERROR;
|
|
|
- spo->o = LSUP_term_new_from_buffer (it->sspo->o);
|
|
|
- if (!spo->o) return LSUP_ERROR;
|
|
|
+ LSUP_Triple *spo = LSUP_triple_new (
|
|
|
+ LSUP_term_new_from_buffer (it->sspo->s),
|
|
|
+ LSUP_term_new_from_buffer (it->sspo->p),
|
|
|
+ LSUP_term_new_from_buffer (it->sspo->o)
|
|
|
+ );
|
|
|
+ if (UNLIKELY (!spo)) return LSUP_MEM_ERR;
|
|
|
+
|
|
|
+ *spo_p = spo;
|
|
|
|
|
|
return LSUP_OK;
|
|
|
}
|
|
@@ -466,8 +467,8 @@ LSUP_graph_contains (const LSUP_Graph *gr, const LSUP_Triple *spo)
|
|
|
{
|
|
|
LSUP_GraphIterator *it = LSUP_graph_lookup (
|
|
|
gr, spo->s, spo->p, spo->o, NULL);
|
|
|
- LSUP_Triple *tmp_spo = TRP_DUMMY;
|
|
|
- bool rc = LSUP_graph_iter_next (it, tmp_spo) != LSUP_END;
|
|
|
+ LSUP_Triple *tmp_spo = NULL;
|
|
|
+ bool rc = LSUP_graph_iter_next (it, &tmp_spo) != LSUP_END;
|
|
|
|
|
|
LSUP_triple_free (tmp_spo);
|
|
|
LSUP_graph_iter_free (it);
|