Exemple #1
0
/* order the list based on the compare function cmp */
list * 
list_order(list *l, fcmp cmp, fdup dup)
{
	list *res = list_new_(l);
	node *m, *n = NULL;

	/* use simple insert sort */
	for (n = l->h; n; n = n->next) {
		int append = 1;
		for (m = res->h; m && append; m = m->next) {
			if (cmp(n->data, m->data) > 0) {
				list_append_before(res, m, dup?dup(n->data):n->data);
				append = 0;
			}
		}
		if (append)
			list_append(res, dup?dup(n->data):n->data);
	}
	return res;
}
Exemple #2
0
void
cs_add_before(changeset * cs, node *n, void *elm)
{
	list_append_before(cs->set, n, elm);
}