Git-Url: 
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=a161e539d50aad0df9ef09790864bf117308c7ee

commit a161e539d50aad0df9ef09790864bf117308c7ee
Author: Michel Hermier <herm...@frugalware.org>
Date:   Fri Jul 29 23:00:48 2011 +0200

db.c: Use _pacman_malloc.

diff --git a/lib/libpacman/db.c b/lib/libpacman/db.c
index d628143..82689de 100644
--- a/lib/libpacman/db.c
+++ b/lib/libpacman/db.c
@@ -52,21 +52,16 @@

pmdb_t *_pacman_db_new(char *root, char* dbpath, const char *treename)
{
-       pmdb_t *db;
+       pmdb_t *db = _pacman_malloc(sizeof(pmdb_t));

-       db = (pmdb_t *)malloc(sizeof(pmdb_t));
if(db == NULL) {
-               _pacman_log(PM_LOG_ERROR, _("malloc failed: could not allocate 
%d bytes"),
-                                 sizeof(pmdb_t));
-               RET_ERR(PM_ERR_MEMORY, NULL);
+               return(NULL);
}

-       db->path = (char 
*)malloc(strlen(root)+strlen(dbpath)+strlen(treename)+2);
+       db->path = 
_pacman_malloc(strlen(root)+strlen(dbpath)+strlen(treename)+2);
if(db->path == NULL) {
-               _pacman_log(PM_LOG_ERROR, _("malloc failed: could not allocate 
%d bytes"),
-                                 
strlen(root)+strlen(dbpath)+strlen(treename)+2);
FREE(db);
-               RET_ERR(PM_ERR_MEMORY, NULL);
+               return(NULL);
}
sprintf(db->path, "%s%s/%s", root, dbpath, treename);
_______________________________________________
Frugalware-git mailing list
Frugalware-git@frugalware.org
http://frugalware.org/mailman/listinfo/frugalware-git

Reply via email to