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>
This commit is contained in:
parent
6444ccbaf0
commit
aa44824788
1 changed files with 9 additions and 2 deletions
|
@ -135,8 +135,15 @@ alpm_file_t SYMEXPORT *alpm_filelist_contains(alpm_filelist_t *filelist,
|
||||||
|
|
||||||
void _alpm_filelist_sort(alpm_filelist_t *filelist)
|
void _alpm_filelist_sort(alpm_filelist_t *filelist)
|
||||||
{
|
{
|
||||||
|
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,
|
qsort(filelist->files, filelist->count,
|
||||||
sizeof(alpm_file_t), _alpm_files_cmp);
|
sizeof(alpm_file_t), _alpm_files_cmp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set noet: */
|
/* vim: set noet: */
|
||||||
|
|
Loading…
Add table
Reference in a new issue