Remove FREEPKG macro and correctly type _alpm_pkg_free

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2007-04-26 21:08:34 -04:00
parent 0984dab1f2
commit a3491224df
9 changed files with 35 additions and 26 deletions

View file

@ -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 */

View file

@ -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);

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);