diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-09 13:54:39 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-09 13:54:39 +0300 |
commit | 0b0dcd114028e1e2a00870917cf07a27858a30b1 (patch) | |
tree | 41aacf9ce3c0cf95aa184545e114175bd352203e /rpmdb | |
parent | 71018d6d2d67b0e17c737e7a90cc6bb704e224ba (diff) | |
download | librpm-tizen-0b0dcd114028e1e2a00870917cf07a27858a30b1.tar.gz librpm-tizen-0b0dcd114028e1e2a00870917cf07a27858a30b1.tar.bz2 librpm-tizen-0b0dcd114028e1e2a00870917cf07a27858a30b1.zip |
Replace alloca+memset with xcalloc() in rpmdbRemove()
- return value is suspect: should return "ret" instead of 0 at exit
depending on what happened in removal but preserving previous behavior
for now...
Diffstat (limited to 'rpmdb')
-rw-r--r-- | rpmdb/rpmdb.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c index 8aafa1330..25d987dc5 100644 --- a/rpmdb/rpmdb.c +++ b/rpmdb/rpmdb.c @@ -2391,8 +2391,8 @@ int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum, rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, char ** msg)) { DBC * dbcursor = NULL; - DBT * key = alloca(sizeof(*key)); - DBT * data = alloca(sizeof(*data)); + DBT * key; + DBT * data; union _dbswap mi_offset; HGE_t hge = (HGE_t)headerGetEntryMinMemory; HFD_t hfd = headerFreeData; @@ -2404,8 +2404,8 @@ int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum, 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)); { rpmdbMatchIterator mi; mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, &hdrNum, sizeof(hdrNum)); @@ -2418,7 +2418,8 @@ int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum, if (h == NULL) { rpmlog(RPMLOG_ERR, _("%s: cannot read header at 0x%x\n"), "rpmdbRemove", hdrNum); - return 1; + ret = 1; + goto exit; } { @@ -2660,7 +2661,12 @@ int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum, h = headerFree(h); /* XXX return ret; */ - return 0; + ret = 0; + +exit: + free(key); + free(data); + return ret; } /* XXX install.c */ |