mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 07:48:50 -05:00
added a FREELISTPTR macro to free a PMList without freeing its data
This commit is contained in:
parent
350a3972d1
commit
0ef95757d6
@ -193,10 +193,7 @@ int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
|
||||
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
|
||||
lp = sortbydeps(trans->packages, PM_TRANS_TYPE_ADD);
|
||||
/* free the old alltargs */
|
||||
for(j = trans->packages; j; j = j->next) {
|
||||
j->data = NULL;
|
||||
}
|
||||
FREELIST(trans->packages);
|
||||
FREELISTPTR(trans->packages);
|
||||
trans->packages = lp;
|
||||
|
||||
TRANS_CB(trans, PM_TRANS_EVT_DEPS_DONE, NULL, NULL);
|
||||
@ -384,13 +381,9 @@ int add_commit(pmdb_t *db, pmtrans_t *trans)
|
||||
cache, thus eliminating the need for db_scan(DEPENDS) */
|
||||
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
||||
if(provides) {
|
||||
PMList *p;
|
||||
/* use the first one */
|
||||
depinfo = db_scan(db, ((pmpkg_t *)provides->data)->name, INFRQ_DESC|INFRQ_DEPENDS);
|
||||
for(p = provides; p; p = p->next) {
|
||||
p->data = NULL;
|
||||
}
|
||||
FREELIST(provides);
|
||||
FREELISTPTR(provides);
|
||||
if(depinfo == NULL) {
|
||||
/* wtf */
|
||||
continue;
|
||||
|
@ -245,7 +245,7 @@ int alpm_db_update(PM_DB *db, char *archive, char *ts)
|
||||
db_free_pkgcache(db);
|
||||
|
||||
/* remove the old dir */
|
||||
_alpm_log(PM_LOG_FLOW2, "removing %s (if it exists)\n", db->path);
|
||||
_alpm_log(PM_LOG_FLOW2, "removing %s/%s (if it exists)\n", db->path);
|
||||
/* ORE
|
||||
We should db_remove each db entry, and not rmrf the top directory */
|
||||
_alpm_rmrf(db->path);
|
||||
|
@ -156,13 +156,9 @@ void db_free_grpcache(pmdb_t *db)
|
||||
}
|
||||
|
||||
for(lg = db->grpcache; lg; lg = lg->next) {
|
||||
PMList *lp;
|
||||
pmgrp_t *grp = lg->data;
|
||||
|
||||
for(lp = grp->packages; lp; lp = lp->next) {
|
||||
lp->data = NULL;
|
||||
}
|
||||
FREELIST(grp->packages);
|
||||
FREELISTPTR(grp->packages);
|
||||
FREEGRP(lg->data);
|
||||
}
|
||||
FREELIST(db->grpcache);
|
||||
|
@ -104,10 +104,7 @@ PMList *sortbydeps(PMList *targets, int mode)
|
||||
}
|
||||
if(clean && change) {
|
||||
/* free up targets -- it's local now */
|
||||
for(i = targets; i; i = i->next) {
|
||||
i->data = NULL;
|
||||
}
|
||||
FREELIST(targets);
|
||||
FREELISTPTR(targets);
|
||||
}
|
||||
targets = newtargs;
|
||||
clean = 1;
|
||||
@ -116,10 +113,7 @@ PMList *sortbydeps(PMList *targets, int mode)
|
||||
/* we're removing packages, so reverse the order */
|
||||
newtargs = _alpm_list_reverse(targets);
|
||||
/* free the old one */
|
||||
for(i = targets; i; i = i->next) {
|
||||
i->data = NULL;
|
||||
}
|
||||
FREELIST(targets);
|
||||
FREELISTPTR(targets);
|
||||
targets = newtargs;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,16 @@ typedef struct __pmlist_t {
|
||||
typedef struct __pmlist_t PMList;
|
||||
|
||||
#define FREELIST(p) do { if(p) { pm_list_free(p); p = NULL; } } while(0)
|
||||
#define FREELISTPTR(p) do { \
|
||||
if(p) { \
|
||||
PMList *i; \
|
||||
for(i = p; i; i = i->next) { \
|
||||
i->data = NULL; \
|
||||
} \
|
||||
pm_list_free(p); \
|
||||
p = NULL; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* Sort comparison callback function declaration */
|
||||
typedef int (*pm_fn_cmp) (const void *, const void *);
|
||||
|
@ -65,7 +65,7 @@ int remove_loadtarget(pmdb_t *db, pmtrans_t *trans, char *name)
|
||||
int remove_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
|
||||
{
|
||||
pmpkg_t *info;
|
||||
PMList *lp, *i;
|
||||
PMList *lp;
|
||||
|
||||
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||
@ -104,10 +104,7 @@ int remove_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
|
||||
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
|
||||
lp = sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE);
|
||||
/* free the old alltargs */
|
||||
for(i = trans->packages; i; i = i->next) {
|
||||
i->data = NULL;
|
||||
}
|
||||
FREELIST(trans->packages);
|
||||
FREELISTPTR(trans->packages);
|
||||
trans->packages = lp;
|
||||
|
||||
TRANS_CB(trans, PM_TRANS_EVT_DEPS_DONE, NULL, NULL);
|
||||
@ -228,16 +225,12 @@ int remove_commit(pmdb_t *db, pmtrans_t *trans)
|
||||
/* look for a provides package */
|
||||
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
||||
if(provides) {
|
||||
PMList *p;
|
||||
/* TODO: should check _all_ packages listed in provides, not just
|
||||
* the first one.
|
||||
*/
|
||||
/* use the first one */
|
||||
depinfo = db_scan(db, ((pmpkg_t *)provides->data)->name, INFRQ_DESC|INFRQ_DEPENDS);
|
||||
for(p = provides; p; p = p->next) {
|
||||
p->data = NULL;
|
||||
}
|
||||
FREELIST(provides);
|
||||
FREELISTPTR(provides);
|
||||
if(depinfo == NULL) {
|
||||
/* wtf */
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user