diff options
author | Dan McGee <dan@archlinux.org> | 2008-01-11 01:00:15 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2008-01-11 22:58:05 -0600 |
commit | 3e133524a54ab55daff666d26c67ac288b605e92 (patch) | |
tree | cc1f0080c28d65ab5c029659a653658c52d748a7 /lib/libalpm/package.c | |
parent | ccc1c731529de16f6fa4064fd992a8f63d7cfc26 (diff) | |
download | pacman-3e133524a54ab55daff666d26c67ac288b605e92.tar.xz |
Add functions to manipulate pmdepend_t objects
We didn't have a free function before, causing some memory leaks. We also
need a dup function now that strings are not in the structure but are
dynamically allocated.
Also adapt pmdepmissing_t to use a pointer to a depend struct instead of an
inclusive one so we can use the functions we created here.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r-- | lib/libalpm/package.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c index a9652f25..7e1bcd55 100644 --- a/lib/libalpm/package.c +++ b/lib/libalpm/package.c @@ -771,6 +771,7 @@ pmpkg_t *_alpm_pkg_new(const char *name, const char *version) pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) { pmpkg_t *newpkg; + alpm_list_t *i; ALPM_LOG_FUNC; @@ -792,13 +793,14 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg) newpkg->force = pkg->force; newpkg->reason = pkg->reason; - newpkg->licenses = alpm_list_strdup(alpm_pkg_get_licenses(pkg)); + newpkg->licenses = alpm_list_strdup(alpm_pkg_get_licenses(pkg)); newpkg->replaces = alpm_list_strdup(alpm_pkg_get_replaces(pkg)); newpkg->groups = alpm_list_strdup(alpm_pkg_get_groups(pkg)); newpkg->files = alpm_list_strdup(alpm_pkg_get_files(pkg)); newpkg->backup = alpm_list_strdup(alpm_pkg_get_backup(pkg)); - newpkg->depends = alpm_list_copy_data(alpm_pkg_get_depends(pkg), - sizeof(pmdepend_t)); + for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) { + newpkg->depends = alpm_list_add(newpkg->depends, _alpm_dep_dup(i->data)); + } newpkg->optdepends = alpm_list_strdup(alpm_pkg_get_optdepends(pkg)); newpkg->conflicts = alpm_list_strdup(alpm_pkg_get_conflicts(pkg)); newpkg->provides = alpm_list_strdup(alpm_pkg_get_provides(pkg)); @@ -838,7 +840,8 @@ void _alpm_pkg_free(pmpkg_t *pkg) FREELIST(pkg->groups); FREELIST(pkg->files); FREELIST(pkg->backup); - FREELIST(pkg->depends); + 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); |