Rev 1757 | Rev 1787 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1757 | Rev 1780 | ||
---|---|---|---|
Line 61... | Line 61... | ||
61 | * @param cmp Comparator function. |
61 | * @param cmp Comparator function. |
62 | * |
62 | * |
63 | */ |
63 | */ |
64 | void qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b)) |
64 | void qsort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b)) |
65 | { |
65 | { |
66 | __u8 buf_tmp[EBUFSIZE]; |
66 | uint8_t buf_tmp[EBUFSIZE]; |
67 | __u8 buf_pivot[EBUFSIZE]; |
67 | uint8_t buf_pivot[EBUFSIZE]; |
68 | void * tmp = buf_tmp; |
68 | void * tmp = buf_tmp; |
69 | void * pivot = buf_pivot; |
69 | void * pivot = buf_pivot; |
70 | 70 | ||
71 | if (e_size > EBUFSIZE) { |
71 | if (e_size > EBUFSIZE) { |
72 | pivot = (void *) malloc(e_size, 0); |
72 | pivot = (void *) malloc(e_size, 0); |
Line 130... | Line 130... | ||
130 | * @param cmp Comparator function. |
130 | * @param cmp Comparator function. |
131 | * |
131 | * |
132 | */ |
132 | */ |
133 | void bubblesort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b)) |
133 | void bubblesort(void * data, count_t n, size_t e_size, int (* cmp) (void * a, void * b)) |
134 | { |
134 | { |
135 | __u8 buf_slot[EBUFSIZE]; |
135 | uint8_t buf_slot[EBUFSIZE]; |
136 | void * slot = buf_slot; |
136 | void * slot = buf_slot; |
137 | 137 | ||
138 | if (e_size > EBUFSIZE) { |
138 | if (e_size > EBUFSIZE) { |
139 | slot = (void *) malloc(e_size, 0); |
139 | slot = (void *) malloc(e_size, 0); |
140 | } |
140 | } |
Line 182... | Line 182... | ||
182 | int int_cmp(void * a, void * b) |
182 | int int_cmp(void * a, void * b) |
183 | { |
183 | { |
184 | return (* (int *) a > * (int*)b) ? 1 : (*(int *)a < * (int *)b) ? -1 : 0; |
184 | return (* (int *) a > * (int*)b) ? 1 : (*(int *)a < * (int *)b) ? -1 : 0; |
185 | } |
185 | } |
186 | 186 | ||
187 | int __u8_cmp(void * a, void * b) |
187 | int uint8_t_cmp(void * a, void * b) |
188 | { |
188 | { |
189 | return (* (__u8 *) a > * (__u8 *)b) ? 1 : (*(__u8 *)a < * (__u8 *)b) ? -1 : 0; |
189 | return (* (uint8_t *) a > * (uint8_t *)b) ? 1 : (*(uint8_t *)a < * (uint8_t *)b) ? -1 : 0; |
190 | } |
190 | } |
191 | 191 | ||
192 | int __u16_cmp(void * a, void * b) |
192 | int uint16_t_cmp(void * a, void * b) |
193 | { |
193 | { |
194 | return (* (__u16 *) a > * (__u16 *)b) ? 1 : (*(__u16 *)a < * (__u16 *)b) ? -1 : 0; |
194 | return (* (uint16_t *) a > * (uint16_t *)b) ? 1 : (*(uint16_t *)a < * (uint16_t *)b) ? -1 : 0; |
195 | } |
195 | } |
196 | 196 | ||
197 | int __u32_cmp(void * a, void * b) |
197 | int uint32_t_cmp(void * a, void * b) |
198 | { |
198 | { |
199 | return (* (__u32 *) a > * (__u32 *)b) ? 1 : (*(__u32 *)a < * (__u32 *)b) ? -1 : 0; |
199 | return (* (uint32_t *) a > * (uint32_t *)b) ? 1 : (*(uint32_t *)a < * (uint32_t *)b) ? -1 : 0; |
200 | } |
200 | } |
201 | 201 | ||
202 | /** @} |
202 | /** @} |
203 | */ |
203 | */ |