list_add_end (tc->unch_sflst, fixture_create(setup, ischecked));
}
+ /* Add teardowns at front so they are run in reverse order. */
if (teardown) {
if (ischecked)
- list_add_end (tc->ch_tflst, fixture_create(teardown, ischecked));
+ list_add_front (tc->ch_tflst, fixture_create(teardown, ischecked));
else
- list_add_end (tc->unch_tflst, fixture_create(teardown, ischecked));
+ list_add_front (tc->unch_tflst, fixture_create(teardown, ischecked));
}
}
return lp;
}
+void list_add_front (List *lp, const void *val)
+{
+ if (lp == NULL)
+ return;
+ maybe_grow(lp);
+ memmove(lp->data + sizeof lp->data[0], lp->data,
+ lp->n_elts * sizeof lp->data[0]);
+ lp->last++;
+ lp->n_elts++;
+ lp->current = 0;
+ lp->data[lp->current] = val;
+}
+
void list_add_end (List *lp, const void *val)
{
if (lp == NULL)
/* Position list at front */
void list_front(List *lp);
+/* Add a value to the front of the list,
+ positioning newly added value as current value.
+ More expensive than list_add_end, as it uses memmove. */
+void list_add_front (List *lp, const void *val);
/* Add a value to the end of the list,
positioning newly added value as current value */