|
1 #include "comparator.h" |
|
2 |
|
3 int ucx_strcmp(void *s1, void *s2, void *data) { |
|
4 return strcmp((char*)s1, (char*)s2); |
|
5 } |
|
6 |
|
7 int ucx_strncmp(void *s1, void *s2, void *n) { |
|
8 return strncmp((char*)s1, (char*)s2, *((size_t*) n)); |
|
9 } |
|
10 |
|
11 int ucx_intcmp(void *i1, void *i2, void *data) { |
|
12 int a = *((int*) i1); |
|
13 int b = *((int*) i2); |
|
14 if (a == b) { |
|
15 return 0; |
|
16 } else { |
|
17 return a < b ? -1 : 1; |
|
18 } |
|
19 } |
|
20 |
|
21 int ucx_ptrcmp(void *ptr1, void *ptr2, void *data) { |
|
22 if (ptr1 == ptr2) { |
|
23 return 0; |
|
24 } else { |
|
25 return ptr1 < ptr2 ? -1 : 1; |
|
26 } |
|
27 } |