From 4db24ca28a31d1d0d97b30b186fd5255a0ae0113 Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 23 Jan 2007 01:34:58 +0000 Subject: * Added some calloc calls to replace the malloc-then-set-to-zero functionality * Fixed -Ss output so as not to call alpm_list_getdata with a NULl list * Added a NULL check in alpm_list_getdata * Fixed alpm_list_add_sorted to properly handle a new / beginning insertions --- lib/libalpm/db.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'lib/libalpm/db.c') diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 84c05ccc..363ce2a5 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -55,14 +55,14 @@ pmdb_t *_alpm_db_new(char *root, char* dbpath, char *treename) { pmdb_t *db; - db = (pmdb_t *)malloc(sizeof(pmdb_t)); + db = calloc(1, sizeof(pmdb_t)); if(db == NULL) { _alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"), sizeof(pmdb_t)); RET_ERR(PM_ERR_MEMORY, NULL); } - db->path = (char *)malloc(strlen(root)+strlen(dbpath)+strlen(treename)+2); + db->path = calloc(1, strlen(root)+strlen(dbpath)+strlen(treename)+2); if(db->path == NULL) { _alpm_log(PM_LOG_ERROR, _("malloc failed: could not allocate %d bytes"), strlen(root)+strlen(dbpath)+strlen(treename)+2); @@ -73,10 +73,6 @@ pmdb_t *_alpm_db_new(char *root, char* dbpath, char *treename) STRNCPY(db->treename, treename, PATH_MAX); - db->pkgcache = NULL; - db->grpcache = NULL; - db->servers = NULL; - return(db); } -- cgit v1.2.3-54-g00ecf