summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2016-12-09 11:14:06 -0500
committerAllan McRae <allan@archlinux.org>2017-01-04 13:59:15 +1000
commit6444ccbaf0c2ff566217eb32e32397868088812f (patch)
tree9405b1b579cab92b67a45a2399d6746cd948e8e8 /lib/libalpm
parent585bd89803a37380f51d625115b58db4012f4df3 (diff)
downloadpacman-6444ccbaf0c2ff566217eb32e32397868088812f.tar.xz
add _alpm_filelist_sort
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/be_local.c4
-rw-r--r--lib/libalpm/be_package.c3
-rw-r--r--lib/libalpm/be_sync.c3
-rw-r--r--lib/libalpm/filelist.c8
-rw-r--r--lib/libalpm/filelist.h2
5 files changed, 11 insertions, 9 deletions
diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
index 4ccbb1bf..97a49688 100644
--- a/lib/libalpm/be_local.c
+++ b/lib/libalpm/be_local.c
@@ -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) {
diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
index 319ccf8b..6859118d 100644
--- a/lib/libalpm/be_package.c
+++ b/lib/libalpm/be_package.c
@@ -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;
}
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 12be2dd0..5f7d31ab 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -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) {
diff --git a/lib/libalpm/filelist.c b/lib/libalpm/filelist.c
index e360b1e9..46fb4b8d 100644
--- a/lib/libalpm/filelist.c
+++ b/lib/libalpm/filelist.c
@@ -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: */
diff --git a/lib/libalpm/filelist.h b/lib/libalpm/filelist.h
index b482c43a..c879058d 100644
--- a/lib/libalpm/filelist.h
+++ b/lib/libalpm/filelist.h
@@ -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 */