1 #include "dlist.h" |
1 #include "dlist.h" |
|
2 |
|
3 UcxDlist *ucx_dlist_clone(UcxDlist *l, copy_func fnc, void *data) { |
|
4 UcxDlist *ret = NULL; |
|
5 while (l != NULL) { |
|
6 if (fnc != NULL) { |
|
7 ret = ucx_dlist_append(ret, fnc(l->data, data)); |
|
8 } else { |
|
9 ret = ucx_dlist_append(ret, l->data); |
|
10 } |
|
11 l = l->next; |
|
12 } |
|
13 return ret; |
|
14 } |
|
15 |
|
16 int ucx_dlist_equals(UcxDlist *l1, UcxDlist *l2, cmp_func fnc, void* data) { |
|
17 if (l1 == l2) return 1; |
|
18 |
|
19 while (l1 != NULL && l2 != NULL) { |
|
20 if (fnc == NULL) { |
|
21 if (l1->data != l2->data) return 0; |
|
22 } else { |
|
23 if (fnc(l1->data, l2->data, data) != 0) return 0; |
|
24 } |
|
25 l1 = l1->next; |
|
26 l2 = l2->next; |
|
27 } |
|
28 |
|
29 return (l1 == NULL && l2 == NULL); |
|
30 } |
2 |
31 |
3 void ucx_dlist_free(UcxDlist *l) { |
32 void ucx_dlist_free(UcxDlist *l) { |
4 UcxDlist *e = l, *f; |
33 UcxDlist *e = l, *f; |
5 while (e != NULL) { |
34 while (e != NULL) { |
6 f = e; |
35 f = e; |