ATF_TC_BODY(slist_test, tc) { SLIST_HEAD(stailhead, entry) head = SLIST_HEAD_INITIALIZER(head); struct entry { SLIST_ENTRY(entry) entries; int i; } *n1, *n2, *n3, *np;
void IT_destroy(IntervalTree *it) { IntervalTreeNode *x = it->root->left; SLIST_HEAD(node_head, nodeent) stuffToFree = SLIST_HEAD_INITIALIZER(stuffToFree); struct nodeent { SLIST_ENTRY(nodeent) link; struct IntervalTreeNode *node; } *np;
END_TEST /* * Insert at the head. Check SLIST_NEXT(). */ START_TEST(SLIST02) { SLIST_HEAD(slisthead_t, node_t) slisthead = SLIST_HEAD_INITIALIZER(slisthead); struct node_t { int data; SLIST_ENTRY(node_t) links; } *elm1, *elm2;
void do_test(unsigned int c) { unsigned int i; struct node *p, *n; SLIST_HEAD(head); for (i = 0; i < c; ++i) { p = (struct node*)malloc(sizeof(*p)); if (!p) { perror("malloc failed"); exit(1); } p->data = c - i; slist_add(&p->slist, &head); } slist_for_each_entry(p, &head, slist) printf("%d ", p->data); printf("\n"); slist_reverse(&head); slist_for_each_entry(p, &head, slist) printf("%d ", p->data); printf("\n"); slist_for_each_entry(p, &head, slist) p->data = (size_t)rand()%100; printf("before sort: "); slist_for_each_entry(p, &head, slist) printf("%d ", p->data); printf("\n"); slist_sort(NULL, &head, int_cmp); printf("after sort: "); slist_for_each_entry(p, &head, slist) printf("%d ", p->data); printf("\n"); slist_for_each_entry_safe(p, n, &head, slist) free(p); }