summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-08-09 08:00:16 +0200
committerDan McGee <dan@archlinux.org>2011-08-15 19:56:41 +0200
commita628feee46f2200db7d3303091813f050a61d0a3 (patch)
tree47e9924d205098c48a6ef3db33e4424b9845c0fc /lib/libalpm/package.c
parentbd5ec9cd8e23bba4334a7b3a5a73843c3667c085 (diff)
downloadpacman-a628feee46f2200db7d3303091813f050a61d0a3.tar.gz
pacman-a628feee46f2200db7d3303091813f050a61d0a3.tar.xz
Parse conflicts/provides/replaces at database load time
We did this with depends way back in commit c244cfecf654d3 in 2007. We can do it with these fields as well. Of note is the inclusion of provides even though only '=' is supported- we'll parse other things, but no guarantees are given as to behavior, which is more or less similar to before since we only looked for the equals sign. Also of note is the non-inclusion of optdepends; this will likely be resolved down the road. The biggest benefactors of this change will be the resolving code that formerly had to parse and reparse several of these fields; it only happens once now at load time. This does lead to the disadvantage that we will now always be parsing this information up front even if we never need it in the split form, but as these are uncommon fields and our parser is quite efficient it shouldn't be a big concern. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index a8dc1440..19d2c844 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -496,7 +496,9 @@ alpm_pkg_t *_alpm_pkg_dup(alpm_pkg_t *pkg)
newpkg->reason = pkg->reason;
newpkg->licenses = alpm_list_strdup(pkg->licenses);
- newpkg->replaces = alpm_list_strdup(pkg->replaces);
+ for(i = pkg->replaces; i; i = alpm_list_next(i)) {
+ newpkg->replaces = alpm_list_add(newpkg->replaces, _alpm_dep_dup(i->data));
+ }
newpkg->groups = alpm_list_strdup(pkg->groups);
if(pkg->files.count) {
size_t filenum;
@@ -517,8 +519,12 @@ alpm_pkg_t *_alpm_pkg_dup(alpm_pkg_t *pkg)
newpkg->depends = alpm_list_add(newpkg->depends, _alpm_dep_dup(i->data));
}
newpkg->optdepends = alpm_list_strdup(pkg->optdepends);
- newpkg->conflicts = alpm_list_strdup(pkg->conflicts);
- newpkg->provides = alpm_list_strdup(pkg->provides);
+ for(i = pkg->conflicts; i; i = alpm_list_next(i)) {
+ newpkg->conflicts = alpm_list_add(newpkg->conflicts, _alpm_dep_dup(i->data));
+ }
+ for(i = pkg->provides; i; i = alpm_list_next(i)) {
+ newpkg->provides = alpm_list_add(newpkg->provides, _alpm_dep_dup(i->data));
+ }
for(i = pkg->deltas; i; i = alpm_list_next(i)) {
newpkg->deltas = alpm_list_add(newpkg->deltas, _alpm_delta_dup(i->data));
}
@@ -557,8 +563,10 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
FREE(pkg->sha256sum);
FREE(pkg->base64_sig);
FREE(pkg->arch);
+
FREELIST(pkg->licenses);
- FREELIST(pkg->replaces);
+ alpm_list_free_inner(pkg->replaces, (alpm_list_fn_free)_alpm_dep_free);
+ alpm_list_free(pkg->replaces);
FREELIST(pkg->groups);
if(pkg->files.count) {
size_t i;
@@ -572,8 +580,10 @@ void _alpm_pkg_free(alpm_pkg_t *pkg)
alpm_list_free_inner(pkg->depends, (alpm_list_fn_free)_alpm_dep_free);
alpm_list_free(pkg->depends);
FREELIST(pkg->optdepends);
- FREELIST(pkg->conflicts);
- FREELIST(pkg->provides);
+ alpm_list_free_inner(pkg->conflicts, (alpm_list_fn_free)_alpm_dep_free);
+ alpm_list_free(pkg->conflicts);
+ alpm_list_free_inner(pkg->provides, (alpm_list_fn_free)_alpm_dep_free);
+ alpm_list_free(pkg->provides);
alpm_list_free_inner(pkg->deltas, (alpm_list_fn_free)_alpm_delta_free);
alpm_list_free(pkg->deltas);
alpm_list_free(pkg->delta_path);