sort-util: make cmp_int() generic, so that we can reuse it elsewhere

This commit is contained in:
Lennart Poettering 2020-11-30 16:23:15 +01:00
parent 8710a6818e
commit 1403d48d61
3 changed files with 6 additions and 4 deletions

View File

@ -211,10 +211,6 @@ static int get_max_fd(void) {
return (int) (m - 1);
}
static int cmp_int(const int *a, const int *b) {
return CMP(*a, *b);
}
int close_all_fds(const int except[], size_t n_except) {
static bool have_close_range = true; /* Assume we live in the future */
_cleanup_closedir_ DIR *d = NULL;

View File

@ -27,3 +27,7 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
}
return NULL;
}
int cmp_int(const int *a, const int *b) {
return CMP(*a, *b);
}

View File

@ -68,3 +68,5 @@ static inline void qsort_r_safe(void *base, size_t nmemb, size_t size, __compar_
int (*_func_)(const typeof(p[0])*, const typeof(p[0])*, typeof(userdata)) = func; \
qsort_r_safe((p), (n), sizeof((p)[0]), (__compar_d_fn_t) _func_, userdata); \
})
int cmp_int(const int *a, const int *b);