|
@@ -137,6 +137,7 @@ LSUP_term_serialize (const LSUP_Term *term)
|
|
) != LSUP_OK) return NULL;
|
|
) != LSUP_OK) return NULL;
|
|
|
|
|
|
tmp_term = LSUP_iriref_new (fq_uri, NULL);
|
|
tmp_term = LSUP_iriref_new (fq_uri, NULL);
|
|
|
|
+ free (fq_uri);
|
|
|
|
|
|
} else if (term->type == LSUP_TERM_LT_LITERAL) {
|
|
} else if (term->type == LSUP_TERM_LT_LITERAL) {
|
|
// For LT literals with empty lang tag, convert to a normal xsd:string.
|
|
// For LT literals with empty lang tag, convert to a normal xsd:string.
|
|
@@ -294,15 +295,13 @@ term_init (
|
|
return LSUP_VALUE_ERR;
|
|
return LSUP_VALUE_ERR;
|
|
}
|
|
}
|
|
|
|
|
|
- if (term->datatype != LSUP_default_datatype) {
|
|
|
|
- uint32_t dtype_hash = LSUP_term_hash (term->datatype );
|
|
|
|
|
|
+ uint32_t dtype_hash = LSUP_term_hash (term->datatype);
|
|
|
|
|
|
- LSUP_Term *tmp = (LSUP_Term *) LSUP_tcache_get (dtype_hash);
|
|
|
|
- if (!tmp) LSUP_tcache_add (dtype_hash, term->datatype);
|
|
|
|
- else if (term->datatype != tmp) {
|
|
|
|
- free (term->datatype);
|
|
|
|
- term->datatype = tmp;
|
|
|
|
- }
|
|
|
|
|
|
+ LSUP_Term *tmp = (LSUP_Term *) LSUP_tcache_get (dtype_hash);
|
|
|
|
+ if (!tmp) LSUP_tcache_add (dtype_hash, term->datatype);
|
|
|
|
+ else if (term->datatype != tmp) {
|
|
|
|
+ LSUP_term_free (term->datatype);
|
|
|
|
+ term->datatype = tmp;
|
|
}
|
|
}
|
|
|
|
|
|
log_trace ("Datatype address: %p", term->datatype);
|
|
log_trace ("Datatype address: %p", term->datatype);
|
|
@@ -334,62 +333,10 @@ LSUP_term_hash (const LSUP_Term *term)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-/* DEPRECATED
|
|
|
|
-bool LSUP_term_equals (const LSUP_Term *term1, const LSUP_Term *term2)
|
|
|
|
-{
|
|
|
|
- LSUP_TermType type1, type2;
|
|
|
|
- char *data1, *data2;
|
|
|
|
-
|
|
|
|
- // Normalize IRI data before comparing.
|
|
|
|
- if (term1->type == LSUP_TERM_NS_IRIREF) {
|
|
|
|
- type1 = LSUP_TERM_IRIREF;
|
|
|
|
- if (UNLIKELY (LSUP_nsmap_normalize_uri (
|
|
|
|
- term1->iri_info->nsm, term1->data, &data1
|
|
|
|
- ) != LSUP_OK)) return LSUP_ERROR;
|
|
|
|
- } else {
|
|
|
|
- type1 = term1->type;
|
|
|
|
- data1 = term1->data;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (term2->type == LSUP_TERM_NS_IRIREF) {
|
|
|
|
- type2 = LSUP_TERM_IRIREF;
|
|
|
|
- if (UNLIKELY (LSUP_nsmap_normalize_uri (
|
|
|
|
- term2->iri_info->nsm, term2->data, &data2
|
|
|
|
- ) != LSUP_OK)) return LSUP_ERROR;
|
|
|
|
- } else {
|
|
|
|
- type2 = term2->type;
|
|
|
|
- data2 = term2->data;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (type1 != type2) return false;
|
|
|
|
-
|
|
|
|
- int cmp = strcmp (data1, data2);
|
|
|
|
- if (term1->type == LSUP_TERM_NS_IRIREF) free (data1);
|
|
|
|
- if (term2->type == LSUP_TERM_NS_IRIREF) free (data2);
|
|
|
|
-
|
|
|
|
- if (cmp != 0) return false;
|
|
|
|
-
|
|
|
|
- if (term1->type == LSUP_TERM_LITERAL)
|
|
|
|
- return term1->datatype == term2->datatype;
|
|
|
|
-
|
|
|
|
- if (term1->type == LSUP_TERM_LT_LITERAL)
|
|
|
|
- return strncmp (term1->lang, term2->lang, sizeof (term1->lang)) == 0;
|
|
|
|
-
|
|
|
|
- return true;
|
|
|
|
-}
|
|
|
|
-*/
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-void LSUP_term_done (LSUP_Term *term)
|
|
|
|
-{
|
|
|
|
- free (term->data);
|
|
|
|
- term->data = NULL;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-
|
|
|
|
void LSUP_term_free (LSUP_Term *term)
|
|
void LSUP_term_free (LSUP_Term *term)
|
|
{
|
|
{
|
|
if (LIKELY (term != NULL)) {
|
|
if (LIKELY (term != NULL)) {
|
|
|
|
+ if (LSUP_IS_IRI (term)) free (term->iri_info);
|
|
free (term->data);
|
|
free (term->data);
|
|
free (term);
|
|
free (term);
|
|
}
|
|
}
|