summaryrefslogtreecommitdiff
path: root/rpmdb
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-09 13:47:29 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-09 13:47:29 +0300
commitf6134083c29c6cbb3be255fadae47a03d35b09f1 (patch)
tree77a80014debca198ee989d6dfa49c29ec43f9f22 /rpmdb
parent2dad3ee0a9ff1ad4a247d863e82c12cd66df3d89 (diff)
downloadlibrpm-tizen-f6134083c29c6cbb3be255fadae47a03d35b09f1.tar.gz
librpm-tizen-f6134083c29c6cbb3be255fadae47a03d35b09f1.tar.bz2
librpm-tizen-f6134083c29c6cbb3be255fadae47a03d35b09f1.zip
Replace alloca+memset with xcalloc() in rpmdbCountPackages()
Diffstat (limited to 'rpmdb')
-rw-r--r--rpmdb/rpmdb.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index 30fd2e2e8..f8798f16e 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -1195,21 +1195,21 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
int rpmdbCountPackages(rpmdb db, const char * name)
{
DBC * dbcursor = NULL;
- DBT * key = alloca(sizeof(*key));
- DBT * data = alloca(sizeof(*data));
+ DBT * key;
+ DBT * data;
dbiIndex dbi;
- int rc;
+ int rc = 0;
int xx;
if (db == NULL)
return 0;
- memset(key, 0, sizeof(*key));
- memset(data, 0, sizeof(*data));
+ key = xcalloc(1, sizeof(*key));
+ data = xcalloc(1, sizeof(*data));
dbi = dbiOpen(db, RPMTAG_NAME, 0);
if (dbi == NULL)
- return 0;
+ goto exit;
key->data = (void *) name;
key->size = strlen(name);
@@ -1245,6 +1245,10 @@ int rpmdbCountPackages(rpmdb db, const char * name)
dbcursor = NULL;
#endif
+exit:
+ free(key);
+ free(data);
+
return rc;
}