add _alpm_filelist_sort
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
585bd89803
commit
6444ccbaf0
5 changed files with 11 additions and 9 deletions
|
@ -817,14 +817,12 @@ static int local_db_read(alpm_pkg_t *info, int inforeq)
|
|||
if(newfiles != NULL) {
|
||||
files = newfiles;
|
||||
}
|
||||
|
||||
/* make sure the list is sorted */
|
||||
qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
|
||||
} else {
|
||||
FREE(files);
|
||||
}
|
||||
info->files.count = files_count;
|
||||
info->files.files = files;
|
||||
_alpm_filelist_sort(&info->files);
|
||||
continue;
|
||||
nomem:
|
||||
while(files_count > 0) {
|
||||
|
|
|
@ -676,8 +676,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
|
|||
_alpm_log(handle, ALPM_LOG_DEBUG,
|
||||
"sorting package filelist for %s\n", pkgfile);
|
||||
|
||||
qsort(newpkg->files.files, newpkg->files.count,
|
||||
sizeof(alpm_file_t), _alpm_files_cmp);
|
||||
_alpm_filelist_sort(&newpkg->files);
|
||||
}
|
||||
newpkg->infolevel |= INFRQ_FILES;
|
||||
}
|
||||
|
|
|
@ -735,13 +735,12 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
|
|||
/* attempt to hand back any memory we don't need */
|
||||
if(files_count > 0) {
|
||||
files = realloc(files, sizeof(alpm_file_t) * files_count);
|
||||
/* make sure the list is sorted */
|
||||
qsort(files, files_count, sizeof(alpm_file_t), _alpm_files_cmp);
|
||||
} else {
|
||||
FREE(files);
|
||||
}
|
||||
pkg->files.count = files_count;
|
||||
pkg->files.files = files;
|
||||
_alpm_filelist_sort(&pkg->files);
|
||||
}
|
||||
}
|
||||
if(ret != ARCHIVE_EOF) {
|
||||
|
|
|
@ -111,7 +111,7 @@ alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
|
|||
|
||||
/* Helper function for comparing files list entries
|
||||
*/
|
||||
int _alpm_files_cmp(const void *f1, const void *f2)
|
||||
static int _alpm_files_cmp(const void *f1, const void *f2)
|
||||
{
|
||||
const alpm_file_t *file1 = f1;
|
||||
const alpm_file_t *file2 = f2;
|
||||
|
@ -133,4 +133,10 @@ alpm_file_t SYMEXPORT *alpm_filelist_contains(alpm_filelist_t *filelist,
|
|||
sizeof(alpm_file_t), _alpm_files_cmp);
|
||||
}
|
||||
|
||||
void _alpm_filelist_sort(alpm_filelist_t *filelist)
|
||||
{
|
||||
qsort(filelist->files, filelist->count,
|
||||
sizeof(alpm_file_t), _alpm_files_cmp);
|
||||
}
|
||||
|
||||
/* vim: set noet: */
|
||||
|
|
|
@ -27,7 +27,7 @@ alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
|
|||
alpm_list_t *_alpm_filelist_intersection(alpm_filelist_t *filesA,
|
||||
alpm_filelist_t *filesB);
|
||||
|
||||
int _alpm_files_cmp(const void *f1, const void *f2);
|
||||
void _alpm_filelist_sort(alpm_filelist_t *filelist);
|
||||
|
||||
#endif /* ALPM_FILELIST_H */
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue