#ifndef _TEST_ASSETS_H #define _TEST_ASSETS_H #include "triple.h" #define NUM_TRP 10 LSUP_Triple *create_triples() { LSUP_Triple *trp; CRITICAL(trp = malloc(NUM_TRP * sizeof(LSUP_Triple))); // These constitute overall 10 individual triples, 8 unique. LSUP_uri_new("urn:s:0", trp[0].s); LSUP_uri_new("urn:p:0", trp[0].p); LSUP_uri_new("urn:o:0", trp[0].o); LSUP_uri_new("urn:s:1", trp[1].s); LSUP_uri_new("urn:p:1", trp[1].p); LSUP_uri_new("urn:o:1", trp[1].o); LSUP_uri_new("urn:s:2", trp[2].s); LSUP_uri_new("urn:p:2", trp[2].p); LSUP_uri_new("urn:o:2", trp[2].o); LSUP_uri_new("urn:s:0", trp[3].s); LSUP_uri_new("urn:p:1", trp[3].p); LSUP_uri_new("urn:o:2", trp[3].o); LSUP_uri_new("urn:s:0", trp[4].s); LSUP_uri_new("urn:p:2", trp[4].p); LSUP_term_new(LSUP_TERM_LITERAL, "String 1", NULL, NULL, trp[4].o); LSUP_uri_new("urn:s:0", trp[5].s); LSUP_uri_new("urn:p:5", trp[5].p); LSUP_term_new( LSUP_TERM_LITERAL, "String 1", "xsd:string", NULL, trp[5].o); LSUP_uri_new("urn:s:1", trp[6].s); LSUP_uri_new("urn:p:6", trp[6].p); LSUP_term_new( LSUP_TERM_LITERAL, "String 1", "xsd:string", "es-ES", trp[6].o); // Let's reuse pointers. Do not double-free. trp[7].s = trp[0].s; // trp[7].p = trp[2].p; // trp[7].o = trp[5].o; // "String 1"^^xsd:string // Duplicate of trp[7]. Do not double-free. trp[8].s = trp[0].s; trp[8].p = trp[2].p; trp[8].o = trp[5].o; // Duplicate of trp[7] from different pointers with same value. // Do not double-free. trp[9].s = trp[5].s; trp[9].p = trp[4].p; trp[9].o = trp[5].o; return trp; } void free_triples(LSUP_Triple *trp) { // Last three triples are second pointers. for(int i=0; i < NUM_TRP - 3; i++) { LSUP_term_free(trp[i].s); LSUP_term_free(trp[i].p); LSUP_term_free(trp[i].o); } free(trp); } #endif