diff options
author | Aurelien Foret <aurelien@archlinux.org> | 2006-01-07 18:25:28 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2006-01-07 18:25:28 +0000 |
commit | e405204915600340180cef61471471929fb0c275 (patch) | |
tree | 1f9aa6460524b97772b95c8b50db358eaa665f27 /lib/libalpm/sync.c | |
parent | fce68beaafade3453b89ade29d95e99ac172de01 (diff) | |
download | pacman-e405204915600340180cef61471471929fb0c275.tar.xz |
removed a restriction: the data parameter of XXX_prepare functions can be NULL
Diffstat (limited to 'lib/libalpm/sync.c')
-rw-r--r-- | lib/libalpm/sync.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 7cbcf8a0..fc962a36 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -346,9 +346,10 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList ** ASSERT(db_local != NULL, RET_ERR(PM_ERR_DB_NULL, -1)); ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); - ASSERT(data != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); - *data = NULL; + if(data) { + *data = NULL; + } if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) { for(i = trans->packages; i; i = i->next) { @@ -395,13 +396,15 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList ** if(!errorout) { errorout = 1; } - if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - FREELIST(*data); - pm_errno = PM_ERR_MEMORY; - goto error; + if(data) { + if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { + FREELIST(*data); + pm_errno = PM_ERR_MEMORY; + goto error; + } + *miss = *(pmdepmissing_t *)i->data; + *data = pm_list_add(*data, miss); } - *miss = *(pmdepmissing_t *)i->data; - *data = pm_list_add(*data, miss); } } if(errorout) { @@ -527,25 +530,29 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList ** /* abort */ _alpm_log(PM_LOG_ERROR, "package conflicts detected"); errorout = 1; - if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - FREELIST(*data); - pm_errno = PM_ERR_MEMORY; - goto error; + if(data) { + if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { + FREELIST(*data); + pm_errno = PM_ERR_MEMORY; + goto error; + } + *miss = *(pmdepmissing_t *)i->data; + *data = pm_list_add(*data, miss); } - *miss = *(pmdepmissing_t *)i->data; - *data = pm_list_add(*data, miss); } } } else { _alpm_log(PM_LOG_ERROR, "%s conflicts with %s", miss->target, miss->depend.name); errorout = 1; - if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { - FREELIST(*data); - pm_errno = PM_ERR_MEMORY; - goto error; + if(data) { + if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) { + FREELIST(*data); + pm_errno = PM_ERR_MEMORY; + goto error; + } + *miss = *(pmdepmissing_t *)i->data; + *data = pm_list_add(*data, miss); } - *miss = *(pmdepmissing_t *)i->data; - *data = pm_list_add(*data, miss); } } } @@ -588,7 +595,9 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList ** _alpm_log(PM_LOG_DEBUG, "checking dependencies of packages designated for removal"); deps = checkdeps(db_local, PM_TRANS_TYPE_REMOVE, list); if(deps) { - *data = deps; + if(data) { + *data = deps; + } pm_errno = PM_ERR_UNSATISFIED_DEPS; goto error; } |