summaryrefslogtreecommitdiff
path: root/src/util.h
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill@shutemov.name>2011-07-01 00:34:23 +0300
committerKirill A. Shutemov <kirill@shutemov.name>2011-07-05 17:52:39 +0300
commitc20ffa6104cf9797a14cc40dcc963102ef9a98a2 (patch)
tree89e846ea6ce3c548e0647c26c9199059a3c4400a /src/util.h
parent8cc16e29e88a02e26b16da66aca6fa589831b76c (diff)
downloadlibgit2-c20ffa6104cf9797a14cc40dcc963102ef9a98a2.tar.gz
util: introduce merge sort routine
In some cases it's important to preserve order of elements with equal keys (stable sort). qsort(3) doesn't define order of elements with equal keys. git__msort() implements merge sort which is stable sort. Implementation taken from git. Function renamed git_qsort() -> git__msort(). Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
Diffstat (limited to 'src/util.h')
-rw-r--r--src/util.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/util.h b/src/util.h
index 0faf7f69c..c9ca4dec0 100644
--- a/src/util.h
+++ b/src/util.h
@@ -118,4 +118,7 @@ extern int git__fnmatch(const char *pattern, const char *name, int flags);
} \
} while (0)
+extern int git__msort(void *b, size_t n, size_t s,
+ int (*cmp)(const void *, const void *));
+
#endif /* INCLUDE_util_h__ */