Browse Source

Adjust profile.c.

scossu 10 months ago
parent
commit
dbb218e03e
1 changed files with 11 additions and 14 deletions
  1. 11 14
      profile.c

+ 11 - 14
profile.c

@@ -3,11 +3,11 @@
 
 #define NT 100000
 
-static LSUP_Triple *
-generate_triples(size_t nt)
+static LSUP_Triple **
+generate_triples (size_t nt)
 {
-    LSUP_Triple *trp;
-    trp = malloc((nt  + 1) * sizeof(LSUP_Triple));
+    LSUP_Triple **trp;
+    trp = malloc((nt  + 1) * sizeof(*trp));
     if (!trp) exit (-1);
 
     for (size_t i = 0; i < nt; i++) {
@@ -16,11 +16,11 @@ generate_triples(size_t nt)
         sprintf(sstr, "urn:s:%lu", i % (nt / 100));
         sprintf(pstr, "urn:p:%lu", i % (nt / 1000));
         sprintf(ostr, "urn:o:%lu", i);
-        LSUP_triple_init(
-                trp + i, LSUP_iriref_new (sstr, NULL),
-                LSUP_iriref_new (pstr, NULL), LSUP_iriref_new (ostr, NULL));
+        trp[i] = LSUP_triple_new(
+                LSUP_iriref_new (sstr, NULL),
+                LSUP_iriref_new (pstr, NULL),
+                LSUP_iriref_new (ostr, NULL));
     }
-    LSUP_triple_init (trp + nt, NULL, NULL, NULL);
     log_info ("Triples generated.");
 
     return trp;
@@ -46,7 +46,7 @@ int main(int argc, char *argv[])
     log_info ("Generating %lu triples.", nt);
     start = clock();
 
-    LSUP_Triple *trp = generate_triples(nt);
+    LSUP_Triple **trp = generate_triples(nt);
     tc1 = clock();
     wallclock = (double) (tc1 - start) / CLOCKS_PER_SEC;
     log_info ("Time elapsed: %lf s", wallclock);
@@ -63,11 +63,8 @@ int main(int argc, char *argv[])
     if (rc != LSUP_OK) log_warn ("Graph loading interrupted: %d.", rc);
     else log_info ("Graph populated with %lu triples.", ct);
 
-    for (size_t i = 0; i < nt; i++) {
-        LSUP_term_free (trp[i].s);
-        LSUP_term_free (trp[i].p);
-        LSUP_term_free (trp[i].o);
-    }
+    for (size_t i = 0; i < nt; i++)
+        LSUP_triple_free (trp[i]);
     free (trp);
 
     tc2 = clock();