qsort_nr.c 316 B

1234567891011121314
  1. #define _BSD_SOURCE
  2. #include <stdlib.h>
  3. typedef int (*cmpfun)(const void *, const void *);
  4. static int wrapper_cmp(const void *v1, const void *v2, void *cmp)
  5. {
  6. return ((cmpfun)cmp)(v1, v2);
  7. }
  8. void qsort(void *base, size_t nel, size_t width, cmpfun cmp)
  9. {
  10. __qsort_r(base, nel, width, wrapper_cmp, (void *)cmp);
  11. }