123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- #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.
- trp[0].s = LSUP_term_new(LSUP_TERM_URI, "urn:s:0", NULL, NULL);
- trp[0].p = LSUP_term_new(LSUP_TERM_URI, "urn:p:0", NULL, NULL);
- trp[0].o = LSUP_term_new(LSUP_TERM_URI, "urn:o:0", NULL, NULL);
- trp[1].s = LSUP_term_new(LSUP_TERM_URI, "urn:s:1", NULL, NULL);
- trp[1].p = LSUP_term_new(LSUP_TERM_URI, "urn:p:1", NULL, NULL);
- trp[1].o = LSUP_term_new(LSUP_TERM_URI, "urn:o:1", NULL, NULL);
- trp[2].s = LSUP_term_new(LSUP_TERM_URI, "urn:s:2", NULL, NULL);
- trp[2].p = LSUP_term_new(LSUP_TERM_URI, "urn:p:2", NULL, NULL);
- trp[2].o = LSUP_term_new(LSUP_TERM_URI, "urn:o:2", NULL, NULL);
- trp[3].s = LSUP_term_new(LSUP_TERM_URI, "urn:s:0", NULL, NULL);
- trp[3].p = LSUP_term_new(LSUP_TERM_URI, "urn:p:1", NULL, NULL);
- trp[3].o = LSUP_term_new(LSUP_TERM_URI, "urn:o:2", NULL, NULL);
- trp[4].s = LSUP_term_new(LSUP_TERM_URI, "urn:s:0", NULL, NULL);
- trp[4].p = LSUP_term_new(LSUP_TERM_URI, "urn:p:2", NULL, NULL);
- trp[4].o = LSUP_term_new(
- LSUP_TERM_LITERAL, "String 1", NULL, NULL);
- trp[5].s = LSUP_term_new(LSUP_TERM_URI, "urn:s:0", NULL, NULL);
- trp[5].p = LSUP_term_new(LSUP_TERM_URI, "urn:p:5", NULL, NULL);
- trp[5].o = LSUP_term_new(
- LSUP_TERM_LITERAL, "String 1", "xsd:string", NULL);
- trp[6].s = LSUP_term_new(LSUP_TERM_URI, "urn:s:1", NULL, NULL);
- trp[6].p = LSUP_term_new(LSUP_TERM_URI, "urn:p:6", NULL, NULL);
- trp[6].o = LSUP_term_new(
- LSUP_TERM_LITERAL, "String 1", "xsd:string", "es-ES");
- // Let's reuse pointers. Do not double-free.
- trp[7].s = trp[0].s; // <urn:s:0>
- trp[7].p = trp[2].p; // <urn:p:2>
- 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
|