added a FREELISTPTR macro to free a PMList without freeing its data
This commit is contained in:
parent
350a3972d1
commit
0ef95757d6
6 changed files with 19 additions and 33 deletions
|
@ -193,10 +193,7 @@ int add_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
|
||||||
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
|
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
|
||||||
lp = sortbydeps(trans->packages, PM_TRANS_TYPE_ADD);
|
lp = sortbydeps(trans->packages, PM_TRANS_TYPE_ADD);
|
||||||
/* free the old alltargs */
|
/* free the old alltargs */
|
||||||
for(j = trans->packages; j; j = j->next) {
|
FREELISTPTR(trans->packages);
|
||||||
j->data = NULL;
|
|
||||||
}
|
|
||||||
FREELIST(trans->packages);
|
|
||||||
trans->packages = lp;
|
trans->packages = lp;
|
||||||
|
|
||||||
TRANS_CB(trans, PM_TRANS_EVT_DEPS_DONE, NULL, NULL);
|
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) */
|
cache, thus eliminating the need for db_scan(DEPENDS) */
|
||||||
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
||||||
if(provides) {
|
if(provides) {
|
||||||
PMList *p;
|
|
||||||
/* use the first one */
|
/* use the first one */
|
||||||
depinfo = db_scan(db, ((pmpkg_t *)provides->data)->name, INFRQ_DESC|INFRQ_DEPENDS);
|
depinfo = db_scan(db, ((pmpkg_t *)provides->data)->name, INFRQ_DESC|INFRQ_DEPENDS);
|
||||||
for(p = provides; p; p = p->next) {
|
FREELISTPTR(provides);
|
||||||
p->data = NULL;
|
|
||||||
}
|
|
||||||
FREELIST(provides);
|
|
||||||
if(depinfo == NULL) {
|
if(depinfo == NULL) {
|
||||||
/* wtf */
|
/* wtf */
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -245,7 +245,7 @@ int alpm_db_update(PM_DB *db, char *archive, char *ts)
|
||||||
db_free_pkgcache(db);
|
db_free_pkgcache(db);
|
||||||
|
|
||||||
/* remove the old dir */
|
/* 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
|
/* ORE
|
||||||
We should db_remove each db entry, and not rmrf the top directory */
|
We should db_remove each db entry, and not rmrf the top directory */
|
||||||
_alpm_rmrf(db->path);
|
_alpm_rmrf(db->path);
|
||||||
|
|
|
@ -156,13 +156,9 @@ void db_free_grpcache(pmdb_t *db)
|
||||||
}
|
}
|
||||||
|
|
||||||
for(lg = db->grpcache; lg; lg = lg->next) {
|
for(lg = db->grpcache; lg; lg = lg->next) {
|
||||||
PMList *lp;
|
|
||||||
pmgrp_t *grp = lg->data;
|
pmgrp_t *grp = lg->data;
|
||||||
|
|
||||||
for(lp = grp->packages; lp; lp = lp->next) {
|
FREELISTPTR(grp->packages);
|
||||||
lp->data = NULL;
|
|
||||||
}
|
|
||||||
FREELIST(grp->packages);
|
|
||||||
FREEGRP(lg->data);
|
FREEGRP(lg->data);
|
||||||
}
|
}
|
||||||
FREELIST(db->grpcache);
|
FREELIST(db->grpcache);
|
||||||
|
|
|
@ -104,10 +104,7 @@ PMList *sortbydeps(PMList *targets, int mode)
|
||||||
}
|
}
|
||||||
if(clean && change) {
|
if(clean && change) {
|
||||||
/* free up targets -- it's local now */
|
/* free up targets -- it's local now */
|
||||||
for(i = targets; i; i = i->next) {
|
FREELISTPTR(targets);
|
||||||
i->data = NULL;
|
|
||||||
}
|
|
||||||
FREELIST(targets);
|
|
||||||
}
|
}
|
||||||
targets = newtargs;
|
targets = newtargs;
|
||||||
clean = 1;
|
clean = 1;
|
||||||
|
@ -116,10 +113,7 @@ PMList *sortbydeps(PMList *targets, int mode)
|
||||||
/* we're removing packages, so reverse the order */
|
/* we're removing packages, so reverse the order */
|
||||||
newtargs = _alpm_list_reverse(targets);
|
newtargs = _alpm_list_reverse(targets);
|
||||||
/* free the old one */
|
/* free the old one */
|
||||||
for(i = targets; i; i = i->next) {
|
FREELISTPTR(targets);
|
||||||
i->data = NULL;
|
|
||||||
}
|
|
||||||
FREELIST(targets);
|
|
||||||
targets = newtargs;
|
targets = newtargs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,16 @@ typedef struct __pmlist_t {
|
||||||
typedef struct __pmlist_t PMList;
|
typedef struct __pmlist_t PMList;
|
||||||
|
|
||||||
#define FREELIST(p) do { if(p) { pm_list_free(p); p = NULL; } } while(0)
|
#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 */
|
/* Sort comparison callback function declaration */
|
||||||
typedef int (*pm_fn_cmp) (const void *, const void *);
|
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)
|
int remove_prepare(pmdb_t *db, pmtrans_t *trans, PMList **data)
|
||||||
{
|
{
|
||||||
pmpkg_t *info;
|
pmpkg_t *info;
|
||||||
PMList *lp, *i;
|
PMList *lp;
|
||||||
|
|
||||||
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_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");
|
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
|
||||||
lp = sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE);
|
lp = sortbydeps(trans->packages, PM_TRANS_TYPE_REMOVE);
|
||||||
/* free the old alltargs */
|
/* free the old alltargs */
|
||||||
for(i = trans->packages; i; i = i->next) {
|
FREELISTPTR(trans->packages);
|
||||||
i->data = NULL;
|
|
||||||
}
|
|
||||||
FREELIST(trans->packages);
|
|
||||||
trans->packages = lp;
|
trans->packages = lp;
|
||||||
|
|
||||||
TRANS_CB(trans, PM_TRANS_EVT_DEPS_DONE, NULL, NULL);
|
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 */
|
/* look for a provides package */
|
||||||
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
PMList *provides = _alpm_db_whatprovides(db, depend.name);
|
||||||
if(provides) {
|
if(provides) {
|
||||||
PMList *p;
|
|
||||||
/* TODO: should check _all_ packages listed in provides, not just
|
/* TODO: should check _all_ packages listed in provides, not just
|
||||||
* the first one.
|
* the first one.
|
||||||
*/
|
*/
|
||||||
/* use the first one */
|
/* use the first one */
|
||||||
depinfo = db_scan(db, ((pmpkg_t *)provides->data)->name, INFRQ_DESC|INFRQ_DEPENDS);
|
depinfo = db_scan(db, ((pmpkg_t *)provides->data)->name, INFRQ_DESC|INFRQ_DEPENDS);
|
||||||
for(p = provides; p; p = p->next) {
|
FREELISTPTR(provides);
|
||||||
p->data = NULL;
|
|
||||||
}
|
|
||||||
FREELIST(provides);
|
|
||||||
if(depinfo == NULL) {
|
if(depinfo == NULL) {
|
||||||
/* wtf */
|
/* wtf */
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Reference in a new issue