Changeset f2460a50 in mainline for uspace/lib/posix/source/stdlib.c
- Timestamp:
- 2017-05-30T06:16:25Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c726209
- Parents:
- 719a208
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/posix/source/stdlib.c
r719a208 rf2460a50 47 47 #include "posix/unistd.h" 48 48 49 #include "libc/ sort.h"49 #include "libc/qsort.h" 50 50 #include "libc/str.h" 51 51 #include "libc/vfs/vfs.h" … … 136 136 137 137 /** 138 * Private helper function that serves as a compare function for qsort().139 *140 * @param elem1 First element to compare.141 * @param elem2 Second element to compare.142 * @param compare Comparison function without userdata parameter.143 * @return Relative ordering of the elements.144 */145 static int sort_compare_wrapper(void *elem1, void *elem2, void *userdata)146 {147 int (*compare)(const void *, const void *) = userdata;148 int ret = compare(elem1, elem2);149 150 /* Native qsort internals expect this. */151 if (ret < 0) {152 return -1;153 } else if (ret > 0) {154 return 1;155 } else {156 return 0;157 }158 }159 160 /**161 138 * Array sorting utilizing the quicksort algorithm. 162 139 * … … 169 146 int (*compare)(const void *, const void *)) 170 147 { 171 /* Implemented in libc with one extra argument. */ 172 qsort(array, count, size, sort_compare_wrapper, compare); 148 qsort(array, count, size, compare); 173 149 } 174 150
Note:
See TracChangeset
for help on using the changeset viewer.