Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2016-12-09 11:14:07 -0500
committerAllan McRae <allan@archlinux.org>2017-01-04 13:59:15 +1000
commitaa44824788582cd3278ff74a60dfb276cf1aebfc (patch)
tree2d6fabd8252c76d881ece6e9345786aec6a12dbd /lib
parent6444ccbaf0c2ff566217eb32e32397868088812f (diff)
filelist_sort: check if filelist is presorted
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/filelist.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/libalpm/filelist.c b/lib/libalpm/filelist.c
index 46fb4b8d..97f639a9 100644
--- a/lib/libalpm/filelist.c
+++ b/lib/libalpm/filelist.c
@@ -135,8 +135,15 @@ alpm_file_t SYMEXPORT *alpm_filelist_contains(alpm_filelist_t *filelist,
void _alpm_filelist_sort(alpm_filelist_t *filelist)
{
- qsort(filelist->files, filelist->count,
- sizeof(alpm_file_t), _alpm_files_cmp);
+ size_t i;
+ for(i = 1; i < filelist->count; i++) {
+ if(strcmp(filelist->files[i - 1].name, filelist->files[i].name) > 0) {
+ /* filelist is not pre-sorted */
+ qsort(filelist->files, filelist->count,
+ sizeof(alpm_file_t), _alpm_files_cmp);
+ return;
+ }
+ }
}
/* vim: set noet: */