The example shows how to inspect statistics.
#include <stdlib.h>
#include <stdio.h>
bool ret = true;
size_t atoms_n;
char *str = NULL;
size_t str_n = 0;
goto error;
}
printf("Model:");
for (it = atoms, ie = atoms + atoms_n; it != ie; ++it) {
size_t n;
char *str_new;
if (str_n < n) {
if (!(str_new = (char*)realloc(str, sizeof(*str) * n))) {
goto error;
}
str = str_new;
str_n = n;
}
printf(" %s", str);
}
printf("\n");
goto out;
error:
ret = false;
out:
if (atoms) { free(atoms); }
if (str) { free(str); }
return ret;
}
(void)data;
(void)goon;
switch (type) {
uint64_t root, values, summary, value;
uint16_t n = 10, random = 1;
double sum = 0;
for (uint16_t i = 0; i < n; ++i) {
random = (random << 3) ^ (random ^ ((random & 0xf800) >> 13)) ^ i;
sum += random;
}
break;
}
}
return true;
}
bool ret = true;
while (true) {
if (model) { print_model(model); }
else { break; }
}
goto out;
error:
ret = false;
out:
}
void print_prefix(int depth) {
for (int i = 0; i < depth; ++i) {
printf(" ");
}
}
bool ret = true;
double value;
print_prefix(depth);
printf("%g\n", value);
break;
}
size_t size;
for (size_t i = 0; i < size; ++i) {
uint64_t subkey;
print_prefix(depth);
printf("%zu:\n", i);
if (!print_statistics(stats, subkey, depth+1)) { goto error; }
}
break;
}
size_t size;
for (size_t i = 0; i < size; ++i) {
char const *name;
uint64_t subkey;
print_prefix(depth);
printf("%s:\n", name);
if (!print_statistics(stats, subkey, depth+1)) { goto error; }
}
}
}
goto out;
error:
ret = false;
out:
return ret;
}
int main(int argc, char const **argv) {
char const *error_message;
int ret = 0;
uint64_t stats_key;
if (!solve(ctl, &solve_ret)) { goto error; }
if (!print_statistics(stats, stats_key, 0)) { goto error; }
goto out;
error:
printf("%s\n", error_message);
out:
return ret;
}