1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-23 08:18:51 -05:00

Remove FREELISTPTR macro

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2007-04-28 03:54:25 -04:00
parent a8b683d8e2
commit a57b2f233f
7 changed files with 20 additions and 22 deletions

View File

@ -249,7 +249,7 @@ int _alpm_add_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
_alpm_log(PM_LOG_DEBUG, _("sorting by dependencies")); _alpm_log(PM_LOG_DEBUG, _("sorting by dependencies"));
lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_ADD); lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_ADD);
/* free the old alltargs */ /* free the old alltargs */
FREELISTPTR(trans->packages); alpm_list_free(trans->packages);
trans->packages = lp; trans->packages = lp;
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL); EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);

View File

@ -43,10 +43,7 @@ struct __alpm_list_t {
struct __alpm_list_t *next; struct __alpm_list_t *next;
}; };
/* TODO we should do away with these... they're messy*/ #define FREELIST(p) do { alpm_list_free_inner(p, free); alpm_list_free(p); p = NULL; } while(0)
#define _FREELIST(p, f) do { alpm_list_free_inner(p, f); alpm_list_free(p); p = NULL; } while(0)
#define FREELIST(p) _FREELIST(p, free)
#define FREELISTPTR(p) do { alpm_list_free(p); p = NULL; } while(0)
typedef void (*alpm_list_fn_free)(void *); /* item deallocation callback */ typedef void (*alpm_list_fn_free)(void *); /* item deallocation callback */
typedef int (*alpm_list_fn_cmp)(const void *, const void *); /* item comparison callback */ typedef int (*alpm_list_fn_cmp)(const void *, const void *); /* item comparison callback */

View File

@ -254,7 +254,8 @@ void _alpm_db_free_grpcache(pmdb_t *db)
for(lg = db->grpcache; lg; lg = lg->next) { for(lg = db->grpcache; lg; lg = lg->next) {
pmgrp_t *grp = lg->data; pmgrp_t *grp = lg->data;
FREELISTPTR(grp->packages); alpm_list_free(grp->packages);
grp->packages = NULL;
_alpm_grp_free(lg->data); _alpm_grp_free(lg->data);
lg->data = NULL; lg->data = NULL;
} }

View File

@ -176,7 +176,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode)
tmptargs = alpm_list_add(tmptargs, p); tmptargs = alpm_list_add(tmptargs, p);
} }
} }
FREELISTPTR(newtargs); alpm_list_free(newtargs);
newtargs = tmptargs; newtargs = tmptargs;
} }
_alpm_log(PM_LOG_DEBUG, _("sorting dependencies finished")); _alpm_log(PM_LOG_DEBUG, _("sorting dependencies finished"));
@ -185,7 +185,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode)
/* we're removing packages, so reverse the order */ /* we're removing packages, so reverse the order */
alpm_list_t *tmptargs = alpm_list_reverse(newtargs); alpm_list_t *tmptargs = alpm_list_reverse(newtargs);
/* free the old one */ /* free the old one */
FREELISTPTR(newtargs); alpm_list_free(newtargs);
newtargs = tmptargs; newtargs = tmptargs;
} }
@ -346,7 +346,6 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
found = alpm_depcmp(p, depend); found = alpm_depcmp(p, depend);
} }
FREELISTPTR(k);
} }
/* check other targets */ /* check other targets */
for(k = packages; k && !found; k = k->next) { for(k = packages; k && !found; k = k->next) {
@ -543,7 +542,7 @@ alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
newtargs = _alpm_removedeps(db, newtargs); newtargs = _alpm_removedeps(db, newtargs);
} }
} }
FREELISTPTR(provides); alpm_list_free(provides);
} else if(can_remove_package(db, deppkg, newtargs)) { } else if(can_remove_package(db, deppkg, newtargs)) {
pmpkg_t *pkg = _alpm_pkg_dup(deppkg); pmpkg_t *pkg = _alpm_pkg_dup(deppkg);
@ -582,7 +581,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
_alpm_log(PM_LOG_DEBUG, _("started resolving dependencies")); _alpm_log(PM_LOG_DEBUG, _("started resolving dependencies"));
targ = alpm_list_add(NULL, syncpkg); targ = alpm_list_add(NULL, syncpkg);
deps = _alpm_checkdeps(trans, local, PM_TRANS_TYPE_ADD, targ); deps = _alpm_checkdeps(trans, local, PM_TRANS_TYPE_ADD, targ);
FREELISTPTR(targ); alpm_list_free(targ);
if(deps == NULL) { if(deps == NULL) {
return(0); return(0);
@ -621,7 +620,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
if(provides) { if(provides) {
sync = provides->data; sync = provides->data;
} }
FREELISTPTR(provides); alpm_list_free(provides);
} }
} }

View File

@ -146,7 +146,7 @@ int _alpm_remove_prepare(pmtrans_t *trans, pmdb_t *db, alpm_list_t **data)
_alpm_log(PM_LOG_DEBUG, _("sorting by dependencies")); _alpm_log(PM_LOG_DEBUG, _("sorting by dependencies"));
lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE); lp = _alpm_sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE);
/* free the old alltargs */ /* free the old alltargs */
FREELISTPTR(trans->packages); alpm_list_free(trans->packages);
trans->packages = lp; trans->packages = lp;
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL); EVENT(trans, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);

View File

@ -286,7 +286,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
} }
_alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ); _alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ);
spkg = _alpm_db_get_pkgfromcache(db, p->data); spkg = _alpm_db_get_pkgfromcache(db, p->data);
FREELISTPTR(p); alpm_list_free(p);
} }
} }
} }
@ -309,7 +309,7 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy
if(p) { if(p) {
_alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ); _alpm_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), p->data, targ);
spkg = _alpm_db_get_pkgfromcache(db, p->data); spkg = _alpm_db_get_pkgfromcache(db, p->data);
FREELISTPTR(p); alpm_list_free(p);
} }
} }
} }
@ -458,8 +458,8 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
} }
} }
} }
FREELISTPTR(k); alpm_list_free(k);
FREELISTPTR(trans->packages); alpm_list_free(trans->packages);
trans->packages = l; trans->packages = l;
EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL); EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_DONE, NULL, NULL);
@ -476,7 +476,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
goto cleanup; goto cleanup;
} }
FREELISTPTR(trail); alpm_list_free(trail);
} }
/* We don't care about conflicts if we're just printing uris */ /* We don't care about conflicts if we're just printing uris */
@ -654,7 +654,8 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL); EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_DONE, NULL, NULL);
} }
FREELISTPTR(list); alpm_list_free(list);
list = NULL;
/* XXX: this fails for cases where a requested package wants /* XXX: this fails for cases where a requested package wants
* a dependency that conflicts with an older version of * a dependency that conflicts with an older version of
@ -764,8 +765,8 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
#endif #endif
cleanup: cleanup:
FREELISTPTR(list); alpm_list_free(list);
FREELISTPTR(trail); alpm_list_free(trail);
FREELIST(asked); FREELIST(asked);
return(ret); return(ret);

View File

@ -330,7 +330,7 @@ int _alpm_trans_update_depends(pmtrans_t *trans, pmpkg_t *pkg)
alpm_pkg_get_name(deppkg), alpm_pkg_get_version(deppkg)); alpm_pkg_get_name(deppkg), alpm_pkg_get_version(deppkg));
} }
} }
FREELISTPTR(provides); alpm_list_free(provides);
if(!found_provides) { if(!found_provides) {
_alpm_log(PM_LOG_DEBUG, _("could not find dependency '%s'"), dep->name); _alpm_log(PM_LOG_DEBUG, _("could not find dependency '%s'"), dep->name);