summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/add.c6
-rw-r--r--lib/libalpm/alpm.c4
-rw-r--r--lib/libalpm/be_files.c2
-rw-r--r--lib/libalpm/cache.c8
-rw-r--r--lib/libalpm/deps.c2
-rw-r--r--lib/libalpm/package.c8
-rw-r--r--lib/libalpm/package.h5
-rw-r--r--lib/libalpm/sync.c19
-rw-r--r--lib/libalpm/trans.c7
9 files changed, 35 insertions, 26 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index adbddb28..ed9b622e 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -124,7 +124,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
/* pm_errno is already set by pkg_load() */
goto error;
}
- FREEPKG(i->data);
+ _alpm_pkg_free(i->data);
i->data = newpkg;
} else {
_alpm_log(PM_LOG_WARNING, _("newer version %s-%s is in the target list -- skipping"),
@@ -156,7 +156,7 @@ int _alpm_add_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
return(0);
error:
- FREEPKG(info);
+ _alpm_pkg_free(info);
return(-1);
}
@@ -836,7 +836,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
EVENT(trans, (is_upgrade) ? PM_TRANS_EVT_UPGRADE_DONE : PM_TRANS_EVT_ADD_DONE, newpkg, oldpkg);
- FREEPKG(oldpkg);
+ _alpm_pkg_free(oldpkg);
}
/* run ldconfig if it exists */
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index fd467bfc..4239430e 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -1128,7 +1128,7 @@ alpm_list_t SYMEXPORT *alpm_get_upgrades()
/* none found -- enter pkg into the final sync list */
sync = _alpm_sync_new(PM_SYNC_TYPE_REPLACE, spkg, NULL);
if(sync == NULL) {
- FREEPKG(dummy);
+ _alpm_pkg_free(dummy);
pm_errno = PM_ERR_MEMORY;
goto error;
}
@@ -1192,7 +1192,7 @@ alpm_list_t SYMEXPORT *alpm_get_upgrades()
}
sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy);
if(sync == NULL) {
- FREEPKG(dummy);
+ _alpm_pkg_free(dummy);
goto error;
}
syncpkgs = alpm_list_add(syncpkgs, sync);
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index 045424c0..8c0b3d69 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -189,7 +189,7 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, const char *target)
/* explicitly read with only 'BASE' data, accessors will handle the rest */
if(_alpm_db_read(db, pkg, INFRQ_BASE) == -1) {
/* TODO removed corrupt entry from the FS here */
- FREEPKG(pkg);
+ _alpm_pkg_free(pkg);
} else {
pkg->data = db;
pkg->origin = PKG_FROM_CACHE;
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index 632a9bbd..72825c00 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -84,7 +84,11 @@ void _alpm_db_free_pkgcache(pmdb_t *db)
_alpm_log(PM_LOG_DEBUG, _("freeing package cache for repository '%s'"),
db->treename);
- FREELISTPKGS(db->pkgcache);
+ alpm_list_t *tmp;
+ for(tmp = db->pkgcache; tmp; tmp = alpm_list_next(tmp)) {
+ _alpm_pkg_free(tmp->data);
+ }
+ db->pkgcache = NULL;
if(db->grpcache) {
_alpm_db_free_grpcache(db);
@@ -157,7 +161,7 @@ int _alpm_db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
return(-1);
}
- FREEPKG(data);
+ _alpm_pkg_free(data);
_alpm_db_free_grpcache(db);
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index 3fdf0676..3a55dae1 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -656,7 +656,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
if(alpm_list_find_str(handle->ignorepkg, alpm_pkg_get_name(sync))) {
pmpkg_t *dummypkg = _alpm_pkg_new(miss->target, NULL);
QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
- FREEPKG(dummypkg);
+ _alpm_pkg_free(dummypkg);
}
if(usedep) {
trail = alpm_list_add(trail, sync);
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 531d91a2..a47ae2fc 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -100,10 +100,8 @@ pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg)
return(newpkg);
}
-void _alpm_pkg_free(void *data)
+void _alpm_pkg_free(pmpkg_t *pkg)
{
- pmpkg_t *pkg = data;
-
ALPM_LOG_FUNC;
if(pkg == NULL) {
@@ -125,8 +123,6 @@ void _alpm_pkg_free(void *data)
FREE(pkg->data);
}
FREE(pkg);
-
- return;
}
/* Is pkgB an upgrade for pkgA ? */
@@ -455,7 +451,7 @@ pkg_invalid:
close(fd);
}
error:
- FREEPKG(info);
+ _alpm_pkg_free(info);
archive_read_finish(archive);
return(NULL);
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 8055c177..212b7a69 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -95,12 +95,9 @@ struct __pmpkg_t {
pmdbinfrq_t infolevel;
};
-#define FREEPKG(p) do { if(p){_alpm_pkg_free(p); p = NULL;}} while(0)
-#define FREELISTPKGS(p) _FREELIST(p, _alpm_pkg_free)
-
pmpkg_t* _alpm_pkg_new(const char *name, const char *version);
pmpkg_t *_alpm_pkg_dup(pmpkg_t *pkg);
-void _alpm_pkg_free(void *data);
+void _alpm_pkg_free(pmpkg_t *pkg);
int _alpm_pkg_cmp(const void *p1, const void *p2);
int alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg);
pmpkg_t *_alpm_pkg_load(const char *pkgfile);
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 10d1eb61..c0b01da0 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -84,9 +84,15 @@ void _alpm_sync_free(pmsyncpkg_t *sync)
/* TODO wow this is ugly */
if(sync->type == PM_SYNC_TYPE_REPLACE) {
- FREELISTPKGS(sync->data);
+ alpm_list_t *tmp;
+ for(tmp = sync->data; tmp; tmp = alpm_list_next(tmp)) {
+ _alpm_pkg_free(tmp->data);
+ tmp->data = NULL;
+ }
+ sync->data = NULL;
} else {
- FREEPKG(sync->data);
+ _alpm_pkg_free(sync->data);
+ sync->data = NULL;
}
FREE(sync);
}
@@ -148,7 +154,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
/* none found -- enter pkg into the final sync list */
sync = _alpm_sync_new(PM_SYNC_TYPE_REPLACE, spkg, NULL);
if(sync == NULL) {
- FREEPKG(dummy);
+ _alpm_pkg_free(dummy);
pm_errno = PM_ERR_MEMORY;
goto error;
}
@@ -229,7 +235,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s
}
sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, tmp);
if(sync == NULL) {
- FREEPKG(tmp);
+ _alpm_pkg_free(tmp);
goto error;
}
trans->packages = alpm_list_add(trans->packages, sync);
@@ -346,7 +352,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
}
sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy);
if(sync == NULL) {
- FREEPKG(dummy);
+ _alpm_pkg_free(dummy);
RET_ERR(PM_ERR_MEMORY, -1);
}
_alpm_log(PM_LOG_DEBUG, _("adding target '%s' to the transaction set"),
@@ -591,7 +597,8 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
if(sync->type != PM_SYNC_TYPE_REPLACE) {
/* switch this sync type to REPLACE */
sync->type = PM_SYNC_TYPE_REPLACE;
- FREEPKG(sync->data);
+ _alpm_pkg_free(sync->data);
+ sync->data = NULL;
}
/* append to the replaces list */
_alpm_log(PM_LOG_DEBUG, _("electing '%s' for removal"), miss->depend.name);
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 54267bfc..e0162524 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -86,8 +86,13 @@ void _alpm_trans_free(pmtrans_t *trans)
}
FREELIST(trans->packages);
} else {
- FREELISTPKGS(trans->packages);
+ alpm_list_t *tmp;
+ for(tmp = trans->packages; tmp; tmp = alpm_list_next(tmp)) {
+ _alpm_pkg_free(tmp->data);
+ tmp->data = NULL;
+ }
}
+ trans->packages = NULL;
FREELIST(trans->skip_add);
FREELIST(trans->skip_remove);