Diff options
Diffstat (limited to '')
| -rw-r--r-- | source/cgit.c | 2 | |
| -rw-r--r-- | source/shared.h | 12 | |
| -rw-r--r-- | source/ui-refs.c | 12 | |
| -rw-r--r-- | source/ui-repolist.c | 2 | |
| -rw-r--r-- | source/ui-stats.c | 2 |
5 files changed, 9 insertions, 21 deletions
diff --git a/source/cgit.c b/source/cgit.c index e0b6adb..da86943 100644 --- a/source/cgit.c +++ b/source/cgit.c @@ -311,7 +311,7 @@ static void parse_args(int argc, const char **argv) } } if (scanned) { - cgit_qsort(cgit_repolist.repos, cgit_repolist.count, sizeof(struct cgit_repo), cmp_repos); + QSORT(cgit_repolist.repos, cgit_repolist.count, cmp_repos); print_repolist(stdout, &cgit_repolist, 0); exit(0); } diff --git a/source/shared.h b/source/shared.h index 2bf305d..e22eb57 100644 --- a/source/shared.h +++ b/source/shared.h @@ -140,16 +140,4 @@ extern int cgit_valid_rev(const char *rev); */ extern int cgit_notes_ref_usable(const char *notes_ref); -/* - * qsort for a list that may be empty. C leaves a null base undefined even - * with nothing to sort, and glibc declares it nonnull, while the lists here - * stay null until their first entry. - */ -static inline void cgit_qsort(void *base, size_t n, size_t size, - int (*cmp)(const void *, const void *)) -{ - if (n) - qsort(base, n, size, cmp); -} - #endif // CGIT_SHARED_H diff --git a/source/ui-refs.c b/source/ui-refs.c index 30f2d07..4099225 100644 --- a/source/ui-refs.c +++ b/source/ui-refs.c @@ -253,9 +253,9 @@ static void print_branches_page(int pagesize) print_branch_header(REF_COLUMNS); collect_branches(&list); - cgit_qsort(list.refs, list.count, sizeof(*list.refs), cmp_date); + QSORT(list.refs, list.count, cmp_date); if (ctx.repo->branch_sort == 0) - cgit_qsort(list.refs, list.count, sizeof(*list.refs), cmp_name); + QSORT(list.refs, list.count, cmp_name); page = page_bounds(pagesize, list.count); @@ -278,7 +278,7 @@ static void print_tags_page(int pagesize) collect_tags(&list); if (list.count == 0) return; - cgit_qsort(list.refs, list.count, sizeof(*list.refs), cmp_date); + QSORT(list.refs, list.count, cmp_date); page = page_bounds(pagesize, list.count); @@ -307,9 +307,9 @@ void cgit_print_branches(int maxcount, int columns) // The date sort covers the list, the name sort only the rows about to // be shown, so the section holds the newest branches rather than the // first ones by name. - cgit_qsort(list.refs, list.count, sizeof(*list.refs), cmp_date); + QSORT(list.refs, list.count, cmp_date); if (ctx.repo->branch_sort == 0) - cgit_qsort(list.refs, maxcount, sizeof(*list.refs), cmp_name); + QSORT(list.refs, maxcount, cmp_name); for (i = 0; i < maxcount; i++) print_branch(list.refs[i], columns); @@ -329,7 +329,7 @@ void cgit_print_tags(int maxcount, int columns) collect_tags(&list); if (list.count == 0) return; - cgit_qsort(list.refs, list.count, sizeof(*list.refs), cmp_date); + QSORT(list.refs, list.count, cmp_date); if (maxcount <= 0 || maxcount > list.count) maxcount = list.count; print_tag_header(columns); diff --git a/source/ui-repolist.c b/source/ui-repolist.c index d2552a6..cd961bf 100644 --- a/source/ui-repolist.c +++ b/source/ui-repolist.c @@ -375,7 +375,7 @@ static int sort_repolist(const char *field) continue; if (column->cmp == cmp_idle || column->cmp == cmp_section) resolve_modtimes(); - cgit_qsort(cgit_repolist.repos, cgit_repolist.count, sizeof(struct cgit_repo), column->cmp); + QSORT(cgit_repolist.repos, cgit_repolist.count, column->cmp); return 1; } return 0; diff --git a/source/ui-stats.c b/source/ui-stats.c index 06ec2bc..1c4d654 100644 --- a/source/ui-stats.c +++ b/source/ui-stats.c @@ -421,7 +421,7 @@ void cgit_show_stats(void) } if (collect_stats(period, &authors)) return; - cgit_qsort(authors.items, authors.nr, sizeof(struct string_list_item), cmp_total_commits); + QSORT(authors.items, authors.nr, cmp_total_commits); top = ctx.qry.ofs; if (!top) |
