diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-09 13:47:29 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-09 13:47:29 +0300 |
commit | f6134083c29c6cbb3be255fadae47a03d35b09f1 (patch) | |
tree | 77a80014debca198ee989d6dfa49c29ec43f9f22 /rpmdb | |
parent | 2dad3ee0a9ff1ad4a247d863e82c12cd66df3d89 (diff) | |
download | librpm-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.c | 16 |
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; } |