Free list after each test
This commit is contained in:
parent
259302b368
commit
d6ecce40f9
|
@ -58,6 +58,17 @@ resultT traverse(nodeT *p) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void teardown(nodeT *p) {
|
||||||
|
nodeT *first = p;
|
||||||
|
do {
|
||||||
|
nodeT *next = p->next;
|
||||||
|
p->value = 0;
|
||||||
|
p->next = NULL;
|
||||||
|
free(p);
|
||||||
|
p = next;
|
||||||
|
} while (p != first);
|
||||||
|
}
|
||||||
|
|
||||||
int main (void) {
|
int main (void) {
|
||||||
size_t n;
|
size_t n;
|
||||||
for (n = 2; ; n *= 2) {
|
for (n = 2; ; n *= 2) {
|
||||||
|
@ -65,5 +76,6 @@ int main (void) {
|
||||||
resultT r = traverse(p);
|
resultT r = traverse(p);
|
||||||
printf("%zu %zu %g %g %" PRIuFAST64 "\n",
|
printf("%zu %zu %g %g %" PRIuFAST64 "\n",
|
||||||
n, r.count, r.total_time, r.avg_time, r.sum);
|
n, r.count, r.total_time, r.avg_time, r.sum);
|
||||||
|
teardown(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue