Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-10-11 00:03:46 +0300
committerJunio C Hamano <gitster@pobox.com>2016-10-11 00:03:46 +0300
commitb8688adb12d086b161aa7c369126bdd56843a01b (patch)
treec1d649861b902b5d72dcd8a0d3d970a2294bf5ef /git-compat-util.h
parenta23ca1b8dc42ffd4de2ef30d67ce1e21ded29886 (diff)
parent7e65c75c31de751f58945a22e91e120c10ab6e87 (diff)
Merge branch 'rs/qsort'
We call "qsort(array, nelem, sizeof(array[0]), fn)", and most of the time third parameter is redundant. A new QSORT() macro lets us omit it. * rs/qsort: show-branch: use QSORT use QSORT, part 2 coccicheck: use --all-includes by default remove unnecessary check before QSORT use QSORT add QSORT
Diffstat (limited to 'git-compat-util.h')
-rw-r--r--git-compat-util.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/git-compat-util.h b/git-compat-util.h
index 0ce2cdfb98..43718dabae 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -985,6 +985,14 @@ void git_qsort(void *base, size_t nmemb, size_t size,
#define qsort git_qsort
#endif
+#define QSORT(base, n, compar) sane_qsort((base), (n), sizeof(*(base)), compar)
+static inline void sane_qsort(void *base, size_t nmemb, size_t size,
+ int(*compar)(const void *, const void *))
+{
+ if (nmemb > 1)
+ qsort(base, nmemb, size, compar);
+}
+
#ifndef REG_STARTEND
#error "Git requires REG_STARTEND support. Compile with NO_REGEX=NeedsStartEnd"
#endif