summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-04-25 20:29:14 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-04-28 10:17:37 +0300
commite96d841a591356dd8fc76c75b87684a1c2e69d18 (patch)
tree9cbe85b174d2911866e77a57abae80c59e24f452
parentf3ead2bb94d4d1451d35f52c4dede180f9895019 (diff)
downloadlibrpm-tizen-e96d841a591356dd8fc76c75b87684a1c2e69d18.tar.gz
librpm-tizen-e96d841a591356dd8fc76c75b87684a1c2e69d18.tar.bz2
librpm-tizen-e96d841a591356dd8fc76c75b87684a1c2e69d18.zip
Revert bunch of alloca() -> xcalloc() changes in rpmdb routines
- reverts the following commits: 0b0dcd114028e1e2a00870917cf07a27858a30b1 71018d6d2d67b0e17c737e7a90cc6bb704e224ba f6134083c29c6cbb3be255fadae47a03d35b09f1
-rw-r--r--rpmdb/rpmdb.c44
1 files changed, 16 insertions, 28 deletions
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index 33f5a9f77..ab69307c2 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -1196,21 +1196,21 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec,
int rpmdbCountPackages(rpmdb db, const char * name)
{
DBC * dbcursor = NULL;
- DBT * key;
- DBT * data;
+ DBT * key = alloca(sizeof(*key));
+ DBT * data = alloca(sizeof(*data));
dbiIndex dbi;
- int rc = 0;
+ int rc;
int xx;
if (db == NULL)
return 0;
- key = xcalloc(1, sizeof(*key));
- data = xcalloc(1, sizeof(*data));
+ memset(key, 0, sizeof(*key));
+ memset(data, 0, sizeof(*data));
dbi = dbiOpen(db, RPMTAG_NAME, 0);
if (dbi == NULL)
- goto exit;
+ return 0;
key->data = (void *) name;
key->size = strlen(name);
@@ -1246,10 +1246,6 @@ int rpmdbCountPackages(rpmdb db, const char * name)
dbcursor = NULL;
#endif
-exit:
- free(key);
- free(data);
-
return rc;
}
@@ -2392,8 +2388,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;
- DBT * data;
+ DBT * key = alloca(sizeof(*key));
+ DBT * data = alloca(sizeof(*data));
union _dbswap mi_offset;
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
@@ -2405,8 +2401,8 @@ int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum,
if (db == NULL)
return 0;
- key = xcalloc(1, sizeof(*key));
- data = xcalloc(1, sizeof(*data));
+ memset(key, 0, sizeof(*key));
+ memset(data, 0, sizeof(*data));
{ rpmdbMatchIterator mi;
mi = rpmdbInitIterator(db, RPMDBI_PACKAGES, &hdrNum, sizeof(hdrNum));
@@ -2419,8 +2415,7 @@ 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);
- ret = 1;
- goto exit;
+ return 1;
}
{
@@ -2662,12 +2657,7 @@ int rpmdbRemove(rpmdb db, int rid, unsigned int hdrNum,
h = headerFree(h);
/* XXX return ret; */
- ret = 0;
-
-exit:
- free(key);
- free(data);
- return ret;
+ return 0;
}
/* XXX install.c */
@@ -2676,8 +2666,8 @@ int rpmdbAdd(rpmdb db, int iid, Header h,
rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, char ** msg))
{
DBC * dbcursor = NULL;
- DBT * key;
- DBT * data;
+ DBT * key = alloca(sizeof(*key));
+ DBT * data = alloca(sizeof(*data));
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
sigset_t signalMask;
@@ -2695,8 +2685,8 @@ int rpmdbAdd(rpmdb db, int iid, Header h,
if (db == NULL)
return 0;
- key = xcalloc(1, sizeof(*key));
- data = xcalloc(1, sizeof(*data));
+ memset(key, 0, sizeof(*key));
+ memset(data, 0, sizeof(*data));
#ifdef NOTYET /* XXX headerRemoveEntry() broken on dribbles. */
xx = headerRemoveEntry(h, RPMTAG_REMOVETID);
@@ -3053,8 +3043,6 @@ int rpmdbAdd(rpmdb db, int iid, Header h,
exit:
(void) unblockSignals(db, &signalMask);
- free(key);
- free(data);
return ret;
}