summaryrefslogtreecommitdiff
path: root/ref-filter.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-01-22 17:58:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-23 19:02:40 (GMT)
commit83fc4d64fec779d73b18494461613ef911236daf (patch)
tree74185498a5c854e0c034059b2efd060e8c2715a9 /ref-filter.c
parent5ebd9472a490b12ff941b8085b1b0932a755ffcc (diff)
downloadgit-83fc4d64fec779d73b18494461613ef911236daf.zip
git-83fc4d64fec779d73b18494461613ef911236daf.tar.gz
git-83fc4d64fec779d73b18494461613ef911236daf.tar.bz2
ref-filter: use QSORT_S in ref_array_sort()
Pass the array of sort keys to compare_refs() via the context parameter of qsort_s() instead of using a global variable; that's cleaner and simpler. If ref_array_sort() is to be called from multiple parallel threads then care still needs to be taken that the global variable used_atom is not modified concurrently. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/ref-filter.c b/ref-filter.c
index f5f7a70..f39e661 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1555,8 +1555,7 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, stru
return (s->reverse) ? -cmp : cmp;
}
-static struct ref_sorting *ref_sorting;
-static int compare_refs(const void *a_, const void *b_)
+static int compare_refs(const void *a_, const void *b_, void *ref_sorting)
{
struct ref_array_item *a = *((struct ref_array_item **)a_);
struct ref_array_item *b = *((struct ref_array_item **)b_);
@@ -1572,8 +1571,7 @@ static int compare_refs(const void *a_, const void *b_)
void ref_array_sort(struct ref_sorting *sorting, struct ref_array *array)
{
- ref_sorting = sorting;
- QSORT(array->items, array->nr, compare_refs);
+ QSORT_S(array->items, array->nr, compare_refs, sorting);
}
static void append_literal(const char *cp, const char *ep, struct ref_formatting_state *state)