added ERROR logs in case of malloc failures (patch from VMiklos <vmiklos@frugalware.org>)

This commit is contained in:
Aurelien Foret 2006-03-01 07:51:00 +00:00
parent ce4c043805
commit 0b4ab2c0a8
4 changed files with 11 additions and 1 deletions

View file

@ -44,7 +44,8 @@ pmdepmissing_t *_alpm_depmiss_new(const char *target, unsigned char type, unsign
miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t));
if(miss == NULL) {
return(NULL);
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t));
RET_ERR(PM_ERR_MEMORY, NULL);
}
STRNCPY(miss->target, target, PKG_NAME_LEN);
@ -566,6 +567,7 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList
miss->target, miss->depend.name);
if(data) {
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
goto error;
@ -605,6 +607,7 @@ int _alpm_resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList
_alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\"", miss->target);
if(data) {
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
goto error;

View file

@ -41,6 +41,7 @@ pmpkg_t *_alpm_pkg_new(const char *name, const char *version)
pkg = (pmpkg_t *)malloc(sizeof(pmpkg_t));
if(pkg == NULL) {
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmpkg_t));
RET_ERR(PM_ERR_MEMORY, NULL);
}

View file

@ -53,6 +53,7 @@ pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, void *data)
pmsyncpkg_t *sync;
if((sync = (pmsyncpkg_t *)malloc(sizeof(pmsyncpkg_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmsyncpkg_t));
return(NULL);
}
@ -571,6 +572,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML
errorout = 1;
if(data) {
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
goto error;
@ -585,6 +587,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML
errorout = 1;
if(data) {
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
goto error;
@ -676,6 +679,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PML
}
if(data) {
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmdepmissing_t));
FREELIST(*data);
pm_errno = PM_ERR_MEMORY;
goto error;

View file

@ -27,6 +27,7 @@
#include "error.h"
#include "package.h"
#include "util.h"
#include "log.h"
#include "list.h"
#include "handle.h"
#include "add.h"
@ -41,6 +42,7 @@ pmtrans_t *_alpm_trans_new()
pmtrans_t *trans;
if((trans = (pmtrans_t *)malloc(sizeof(pmtrans_t))) == NULL) {
_alpm_log(PM_LOG_ERROR, "malloc failure: could not allocate %d bytes", sizeof(pmtrans_t));
return(NULL);
}