summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--beecrypt/config.h2
-rw-r--r--lib/depends.c2
-rw-r--r--lib/rpmlib.h6
-rw-r--r--rpm.spec.in11
-rw-r--r--rpmdb/db3.c4
-rw-r--r--rpmdb/dbconfig.c2
-rw-r--r--rpmdb/rpmdb.c370
-rw-r--r--rpmdb/rpmdb.h10
-rw-r--r--zlib/configure.in1
10 files changed, 244 insertions, 165 deletions
diff --git a/CHANGES b/CHANGES
index 5dc9af4ab..ff8f220ae 100644
--- a/CHANGES
+++ b/CHANGES
@@ -107,6 +107,7 @@
- rip out two layers of dbN gook, internal Berkeley db is here to stay.
- eliminate db1 support.
- enable CDB by default.
+ - use DBT_DB_MALLOC to eliminate re-malloc'ing header blobs.
4.0.3 -> 4.0.4:
- solaris: translate i86pc to i386 (#57182).
diff --git a/beecrypt/config.h b/beecrypt/config.h
index e7d3b2631..395f05f49 100644
--- a/beecrypt/config.h
+++ b/beecrypt/config.h
@@ -50,7 +50,7 @@
#define LEADING_UNDERSCORE 0
#define NO_UNDERSCORES 1
-#define JAVAGLUE 0
+#define JAVAGLUE 1
#define HAVE_ERRNO_H 1
#define HAVE_STRING_H 1
diff --git a/lib/depends.c b/lib/depends.c
index 1c77b38eb..334e505b2 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -367,7 +367,7 @@ static int unsatisfiedDepend(rpmTransactionSet ts, rpmDepSet dep)
memset(data, 0, sizeof(*data));
data->data = datap;
data->size = datalen;
- xx = dbiGet(dbi, dbcursor, key, data, 0);
+ xx = dbiGet(dbi, dbcursor, key, data, DB_SET);
DNEVR = key->data;
DNEVRlen = key->size;
datap = data->data;
diff --git a/lib/rpmlib.h b/lib/rpmlib.h
index a8c3f873b..904eca36c 100644
--- a/lib/rpmlib.h
+++ b/lib/rpmlib.h
@@ -913,7 +913,7 @@ int rpmdbSetIteratorModified(/*@null@*/ rpmdbMatchIterator mi, int modified)
* @return NULL on failure
*/
/*@only@*/ /*@null@*/ rpmdbMatchIterator rpmdbInitIterator(
- /*@null@*/ rpmdb db, int rpmtag,
+ /*@null@*/ rpmdb db, rpmTag rpmtag,
/*@null@*/ const void * keyp, size_t keylen)
/*@globals fileSystem @*/
/*@modifies db, fileSystem @*/;
@@ -946,8 +946,8 @@ int rpmdbRemove(/*@null@*/ rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum)
* @return 0 on success
*/
int rpmdbRebuild(/*@null@*/ const char * prefix)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem @*/
+ /*@modifies rpmGlobalMacroContext, fileSystem @*/;
/*@}*/
/* ==================================================================== */
diff --git a/rpm.spec.in b/rpm.spec.in
index df0b8f20f..19f6b7d41 100644
--- a/rpm.spec.in
+++ b/rpm.spec.in
@@ -20,7 +20,7 @@ Name: rpm
%define version @VERSION@
Version: %{version}
%{expand: %%define rpm_version %{version}}
-Release: 0.11
+Release: 0.12
Group: System Environment/Base
Source: ftp://ftp.rpm.org/pub/rpm/dist/rpm-4.0.x/rpm-%{rpm_version}.tar.gz
Copyright: GPL
@@ -521,15 +521,18 @@ fi
%{__prefix}/include/popt.h
%changelog
-* Thu May 2 2002 Jeff Johnson <jbj@redhat.com>
+* Fri May 3 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.12
+- use DBT_DB_MALLOC to eliminate re-malloc'ing header blobs.
+
+* Thu May 2 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.11
- eliminate db1 support.
- enable CDB by default.
-* Wed May 1 2002 Jeff Johnson <jbj@redhat.com>
+* Wed May 1 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.10
- attempt to make peace with automake-1.6.1, autoconf-2.53.
- rip out two layers of dbN gook, internal Berkeley db is here to stay.
-* Fri Apr 19 2002 Jeff Johnson <jbj@redhat.com>
+* Fri Apr 19 2002 Jeff Johnson <jbj@redhat.com> 4.1-0.09
- fix: queries that evaluated to "" incorrectly returned NULL.
- fix: packages produced by rpm-4.0 dinna merge signature tags.
diff --git a/rpmdb/db3.c b/rpmdb/db3.c
index 28bc26a2d..9c0f3c334 100644
--- a/rpmdb/db3.c
+++ b/rpmdb/db3.c
@@ -422,6 +422,7 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
if (dbcursor == NULL) {
int _printit;
+ /* XXX duplicates require cursors. */
rc = db->get(db, dbi->dbi_txnid, key, data, 0);
/* XXX DB_NOTFOUND can be returned */
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
@@ -430,8 +431,7 @@ static int db3cget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
int _printit;
/* XXX db3 does DB_FIRST on uninitialized cursor */
- rc = dbcursor->c_get(dbcursor, key, data,
- key->data == NULL ? DB_NEXT : DB_SET);
+ rc = dbcursor->c_get(dbcursor, key, data, flags);
/* XXX DB_NOTFOUND can be returned */
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
rc = cvtdberr(dbi, "dbcursor->c_get", rc, _printit);
diff --git a/rpmdb/dbconfig.c b/rpmdb/dbconfig.c
index d442ccbf8..31bf44d82 100644
--- a/rpmdb/dbconfig.c
+++ b/rpmdb/dbconfig.c
@@ -319,7 +319,7 @@ dbiIndex db3Free(dbiIndex dbi)
static const char *db3_config_default =
"db3:hash:mpool:cdb:usecursors:verbose:mp_mmapsize=8Mb:mp_size=512Kb:pagesize=512:perms=0644";
-dbiIndex db3New(rpmdb rpmdb, int rpmtag)
+dbiIndex db3New(rpmdb rpmdb, rpmTag rpmtag)
{
dbiIndex dbi = xcalloc(1, sizeof(*dbi));
char dbiTagMacro[128];
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index ae5fe1e0b..f23cbf47b 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -212,7 +212,7 @@ static struct _dbiVec *mydbvecs[] = {
};
/*@=nullassign@*/
-dbiIndex dbiOpen(rpmdb db, int rpmtag, /*@unused@*/ unsigned int flags)
+dbiIndex dbiOpen(rpmdb db, rpmTag rpmtag, /*@unused@*/ unsigned int flags)
{
int dbix;
dbiIndex dbi = NULL;
@@ -338,83 +338,158 @@ union _dbswap {
}
/**
- * Return items that match criteria.
+ * Convert retrieved data to index set.
+ * @param dbi index database handle
+ * @param data retrieved data
+ * @retval setp (malloc'ed) index set
+ * @return 0 on success
+ */
+static int dbt2set(dbiIndex dbi, DBT * data, dbiIndexSet * setp)
+ /*@modifies *setp @*/
+{
+ int _dbbyteswapped = dbiByteSwapped(dbi);
+ const char * sdbir;
+ dbiIndexSet set;
+ int i;
+
+ if (dbi == NULL || data == NULL || setp == NULL)
+ return -1;
+
+ if ((sdbir = data->data) == NULL) {
+ *setp = NULL;
+ return 0;
+ }
+
+ set = xmalloc(sizeof(*set));
+ set->count = data->size / dbi->dbi_jlen;
+ set->recs = xmalloc(set->count * sizeof(*(set->recs)));
+
+ switch (dbi->dbi_jlen) {
+ default:
+ case 2*sizeof(int_32):
+ for (i = 0; i < set->count; i++) {
+ union _dbswap hdrNum, tagNum;
+
+ memcpy(&hdrNum.ui, sdbir, sizeof(hdrNum.ui));
+ sdbir += sizeof(hdrNum.ui);
+ memcpy(&tagNum.ui, sdbir, sizeof(tagNum.ui));
+ sdbir += sizeof(tagNum.ui);
+ if (_dbbyteswapped) {
+ _DBSWAP(hdrNum);
+ _DBSWAP(tagNum);
+ }
+ set->recs[i].hdrNum = hdrNum.ui;
+ set->recs[i].tagNum = tagNum.ui;
+ set->recs[i].fpNum = 0;
+ set->recs[i].dbNum = 0;
+ }
+ break;
+ case 1*sizeof(int_32):
+ for (i = 0; i < set->count; i++) {
+ union _dbswap hdrNum;
+
+ memcpy(&hdrNum.ui, sdbir, sizeof(hdrNum.ui));
+ sdbir += sizeof(hdrNum.ui);
+ if (_dbbyteswapped) {
+ _DBSWAP(hdrNum);
+ }
+ set->recs[i].hdrNum = hdrNum.ui;
+ set->recs[i].tagNum = 0;
+ set->recs[i].fpNum = 0;
+ set->recs[i].dbNum = 0;
+ }
+ break;
+ }
+ *setp = set;
+ return 0;
+}
+
+/**
+ * Convert index set to database representation.
+ * @param dbi index database handle
+ * @param data retrieved data
+ * @param set index set
+ * @return 0 on success
+ */
+static int set2dbt(dbiIndex dbi, DBT * data, dbiIndexSet set)
+ /*@modifies *data @*/
+{
+ int _dbbyteswapped = dbiByteSwapped(dbi);
+ char * tdbir;
+ int i;
+
+ if (dbi == NULL || data == NULL || set == NULL)
+ return -1;
+
+ data->size = set->count * (dbi->dbi_jlen);
+ if (data->size <= 0) {
+ data->data = NULL;
+ return 0;
+ }
+ tdbir = data->data = xmalloc(data->size);
+
+ switch (dbi->dbi_jlen) {
+ default:
+ case 2*sizeof(int_32):
+ for (i = 0; i < set->count; i++) {
+ union _dbswap hdrNum, tagNum;
+
+ memset(&hdrNum, 0, sizeof(hdrNum));
+ memset(&tagNum, 0, sizeof(tagNum));
+ hdrNum.ui = set->recs[i].hdrNum;
+ tagNum.ui = set->recs[i].tagNum;
+ if (_dbbyteswapped) {
+ _DBSWAP(hdrNum);
+ _DBSWAP(tagNum);
+ }
+ memcpy(tdbir, &hdrNum.ui, sizeof(hdrNum.ui));
+ tdbir += sizeof(hdrNum.ui);
+ memcpy(tdbir, &tagNum.ui, sizeof(tagNum.ui));
+ tdbir += sizeof(tagNum.ui);
+ }
+ break;
+ case 1*sizeof(int_32):
+ for (i = 0; i < set->count; i++) {
+ union _dbswap hdrNum;
+
+ memset(&hdrNum, 0, sizeof(hdrNum));
+ hdrNum.ui = set->recs[i].hdrNum;
+ if (_dbbyteswapped) {
+ _DBSWAP(hdrNum);
+ }
+ memcpy(tdbir, &hdrNum.ui, sizeof(hdrNum.ui));
+ tdbir += sizeof(hdrNum.ui);
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/**
+ * Return index set from key match.
* @param dbi index database handle
* @param dbcursor index database cursor
* @param key search key/length
- * @retval setp address of items retrieved from index database
+ * @param data search data/length
+ * @param flags search flags
* @return -1 error, 0 success, 1 not found
*/
-static int dbiSearch(dbiIndex dbi, DBC * dbcursor, DBT * key,
- /*@out@*/ dbiIndexSet * setp)
+static int dbiSearch(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
+ int flags)
/*@globals fileSystem @*/
- /*@modifies *dbcursor, *setp, fileSystem @*/
+ /*@modifies *dbcursor, fileSystem @*/
{
- DBT * data = alloca(sizeof(*data));
int rc;
+assert(flags == DB_SET);
assert(key->size != 0);
- memset(data, 0, sizeof(*data));
- rc = dbiGet(dbi, dbcursor, key, data, 0);
+ rc = dbiGet(dbi, dbcursor, key, data, flags);
if (rc > 0) {
rpmError(RPMERR_DBGETINDEX,
_("error(%d) getting \"%s\" records from %s index\n"),
rc, key->data, tagName(dbi->dbi_rpmtag));
- } else
- if (rc == 0 && setp) {
- int _dbbyteswapped = dbiByteSwapped(dbi);
- const char * sdbir = data->data;
- dbiIndexSet set;
- int i;
-
- set = xmalloc(sizeof(*set));
-
- /* Convert to database internal format */
- if (sdbir)
- switch (dbi->dbi_jlen) {
- default:
- case 2*sizeof(int_32):
- set->count = data->size / (2*sizeof(int_32));
- set->recs = xmalloc(set->count * sizeof(*(set->recs)));
- for (i = 0; i < set->count; i++) {
- union _dbswap hdrNum, tagNum;
-
- memcpy(&hdrNum.ui, sdbir, sizeof(hdrNum.ui));
- sdbir += sizeof(hdrNum.ui);
- memcpy(&tagNum.ui, sdbir, sizeof(tagNum.ui));
- sdbir += sizeof(tagNum.ui);
- if (_dbbyteswapped) {
- _DBSWAP(hdrNum);
- _DBSWAP(tagNum);
- }
- set->recs[i].hdrNum = hdrNum.ui;
- set->recs[i].tagNum = tagNum.ui;
- set->recs[i].fpNum = 0;
- set->recs[i].dbNum = 0;
- }
- break;
- case 1*sizeof(int_32):
- set->count = data->size / (1*sizeof(int_32));
- set->recs = xmalloc(set->count * sizeof(*(set->recs)));
- for (i = 0; i < set->count; i++) {
- union _dbswap hdrNum;
-
- memcpy(&hdrNum.ui, sdbir, sizeof(hdrNum.ui));
- sdbir += sizeof(hdrNum.ui);
- if (_dbbyteswapped) {
- _DBSWAP(hdrNum);
- }
- set->recs[i].hdrNum = hdrNum.ui;
- set->recs[i].tagNum = 0;
- set->recs[i].fpNum = 0;
- set->recs[i].dbNum = 0;
- }
- break;
- }
- /*@-branchstate@*/
- if (setp) *setp = set;
- /*@=branchstate@*/
}
return rc;
}
@@ -424,72 +499,21 @@ assert(key->size != 0);
* @param dbi index database handle
* @param dbcursor index database cursor
* @param key update key/length
- * @param set items to update in index database
+ * @param data update data/length
+ * @param flags update flags
* @return 0 success, 1 not found
*/
/*@-compmempass -mustmod@*/
-static int dbiUpdateIndex(dbiIndex dbi, DBC * dbcursor, DBT * key,
- dbiIndexSet set)
+static int dbiUpdateIndex(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
+ int flags)
/*@globals fileSystem @*/
- /*@modifies *dbcursor, set, fileSystem @*/
+ /*@modifies *dbcursor, fileSystem @*/
{
- DBT * data = alloca(sizeof(*data));
- void * datap = NULL;
- size_t datalen = 0;
int rc;
- if (set->count) {
- char * tdbir;
- int i;
- int _dbbyteswapped = dbiByteSwapped(dbi);
-
- /* Convert to database internal format */
-
- switch (dbi->dbi_jlen) {
- default:
- case 2*sizeof(int_32):
- datalen = set->count * (2 * sizeof(int_32));
- datap = tdbir = alloca(datalen);
- for (i = 0; i < set->count; i++) {
- union _dbswap hdrNum, tagNum;
-
- memset(&hdrNum, 0, sizeof(hdrNum));
- memset(&tagNum, 0, sizeof(tagNum));
- hdrNum.ui = set->recs[i].hdrNum;
- tagNum.ui = set->recs[i].tagNum;
- if (_dbbyteswapped) {
- _DBSWAP(hdrNum);
- _DBSWAP(tagNum);
- }
- memcpy(tdbir, &hdrNum.ui, sizeof(hdrNum.ui));
- tdbir += sizeof(hdrNum.ui);
- memcpy(tdbir, &tagNum.ui, sizeof(tagNum.ui));
- tdbir += sizeof(tagNum.ui);
- }
- break;
- case 1*sizeof(int_32):
- datalen = set->count * (1 * sizeof(int_32));
- datap = tdbir = alloca(datalen);
- for (i = 0; i < set->count; i++) {
- union _dbswap hdrNum;
-
- memset(&hdrNum, 0, sizeof(hdrNum));
- hdrNum.ui = set->recs[i].hdrNum;
- if (_dbbyteswapped) {
- _DBSWAP(hdrNum);
- }
- memcpy(tdbir, &hdrNum.ui, sizeof(hdrNum.ui));
- tdbir += sizeof(hdrNum.ui);
- }
- break;
- }
+ if (data->data && data->size > 0) {
- memset(data, 0, sizeof(*data));
- data->data = datap;
- data->size = datalen;
-/*@-compdef@*/
- rc = dbiPut(dbi, dbcursor, key, data, 0);
-/*@=compdef@*/
+ rc = dbiPut(dbi, dbcursor, key, data, flags);
if (rc) {
rpmError(RPMERR_DBPUTINDEX,
@@ -499,12 +523,7 @@ static int dbiUpdateIndex(dbiIndex dbi, DBC * dbcursor, DBT * key,
} else {
- memset(data, 0, sizeof(*data));
- data->data = datap;
- data->size = datalen;
-/*@-compdef@*/
- rc = dbiDel(dbi, dbcursor, key, data, 0);
-/*@=compdef@*/
+ rc = dbiDel(dbi, dbcursor, key, data, flags);
if (rc) {
rpmError(RPMERR_DBPUTINDEX,
@@ -1004,6 +1023,7 @@ static int rpmdbFindByFile(rpmdb db, /*@null@*/ const char * filespec,
/*@modifies db, *matches, fileSystem @*/
{
DBT * key = alloca(sizeof(*key));
+DBT * data = alloca(sizeof(*data));
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
const char * dirName;
@@ -1021,6 +1041,7 @@ DBT * key = alloca(sizeof(*key));
*matches = NULL;
if (filespec == NULL) return -2;
+
/*@-branchstate@*/
if ((baseName = strrchr(filespec, '/')) != NULL) {
char * t;
@@ -1043,6 +1064,7 @@ DBT * key = alloca(sizeof(*key));
fp1 = fpLookup(fpc, dirName, baseName, 1);
dbi = dbiOpen(db, RPMTAG_BASENAMES, 0);
+/*@-branchstate@*/
if (dbi != NULL) {
dbcursor = NULL;
xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, 0);
@@ -1052,11 +1074,16 @@ key->data = (void *) baseName;
key->size = strlen(baseName);
if (key->size == 0) key->size++; /* XXX "/" fixup. */
- rc = dbiSearch(dbi, dbcursor, key, &allMatches);
+memset(data, 0, sizeof(*data));
+ rc = dbiSearch(dbi, dbcursor, key, data, DB_SET);
+if (rc == 0)
+xx = dbt2set(dbi, data, &allMatches);
+
xx = dbiCclose(dbi, dbcursor, 0);
dbcursor = NULL;
} else
rc = -2;
+/*@=branchstate@*/
if (rc) {
allMatches = dbiFreeIndexSet(allMatches);
@@ -1133,6 +1160,7 @@ if (key->size == 0) key->size++; /* XXX "/" fixup. */
int rpmdbCountPackages(rpmdb db, const char * name)
{
DBT * key = alloca(sizeof(*key));
+DBT * data = alloca(sizeof(*data));
dbiIndex dbi;
dbiIndexSet matches = NULL;
int rc = -1;
@@ -1149,16 +1177,23 @@ DBT * key = alloca(sizeof(*key));
return 0;
dbi = dbiOpen(db, RPMTAG_NAME, 0);
+/*@-branchstate@*/
if (dbi) {
DBC * dbcursor = NULL;
xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, 0);
memset(key, 0, sizeof(*key));
+/*@-temptrans@*/
key->data = (void *) name;
+/*@=temptrans@*/
key->size = strlen(name);
- rc = dbiSearch(dbi, dbcursor, key, &matches);
+memset(data, 0, sizeof(*data));
+ rc = dbiSearch(dbi, dbcursor, key, data, DB_SET);
+if (rc == 0)
+xx = dbt2set(dbi, data, &matches);
xx = dbiCclose(dbi, dbcursor, 0);
dbcursor = NULL;
}
+/*@=branchstate@*/
/*@-nullpass@*/ /* FIX: matches might be NULL */
if (rc == 0) /* success */
@@ -1197,14 +1232,19 @@ static int dbiFindMatches(dbiIndex dbi, DBC * dbcursor,
/*@modifies dbi, *dbcursor, *matches, fileSystem @*/
{
DBT * key = alloca(sizeof(*key));
+DBT * data = alloca(sizeof(*data));
int gotMatches;
int rc;
+int xx;
int i;
memset(key, 0, sizeof(*key));
key->data = (void *) name;
key->size = strlen(name);
- rc = dbiSearch(dbi, dbcursor, key, matches);
+memset(data, 0, sizeof(*data));
+ rc = dbiSearch(dbi, dbcursor, key, data, DB_SET);
+if (rc == 0)
+xx = dbt2set(dbi, data, matches);
if (rc != 0) {
rc = ((rc == -1) ? 2 : 1);
@@ -1964,7 +2004,8 @@ top:
data->data = uh;
data->size = uhlen;
data->flags |= DB_DBT_MALLOC;
- rc = dbiGet(dbi, mi->mi_dbc, key, data, 0);
+ rc = dbiGet(dbi, mi->mi_dbc, key, data,
+ (key->data == NULL ? DB_NEXT : DB_SET));
keyp = key->data;
keylen = key->size;
uh = data->data;
@@ -2007,7 +2048,7 @@ if (dbi->dbi_api == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES && rc == EFAULT) {
key->size = keylen;
memset(data, 0, sizeof(*data));
data->flags |= DB_DBT_MALLOC;
- rc = dbiGet(dbi, mi->mi_dbc, key, data, 0);
+ rc = dbiGet(dbi, mi->mi_dbc, key, data, DB_SET);
keyp = key->data;
keylen = key->size;
uh = data->data;
@@ -2096,6 +2137,7 @@ static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi, DBT * key,
/*@globals fileSystem @*/
/*@modifies mi, fileSystem @*/
{
+DBT * data = alloca(sizeof(*data));
dbiIndex dbi = NULL;
DBC * dbcursor = NULL;
dbiIndexSet set = NULL;
@@ -2110,7 +2152,10 @@ static int rpmdbGrowIterator(/*@null@*/ rpmdbMatchIterator mi, DBT * key,
return 1;
xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, 0);
- rc = dbiSearch(dbi, dbcursor, key, &set);
+memset(data, 0, sizeof(*data));
+ rc = dbiSearch(dbi, dbcursor, key, data, DB_SET);
+if (rc == 0)
+xx = dbt2set(dbi, data, &set);
xx = dbiCclose(dbi, dbcursor, 0);
dbcursor = NULL;
@@ -2157,10 +2202,11 @@ int rpmdbAppendIterator(rpmdbMatchIterator mi, const int * hdrNums, int nHdrNums
return 0;
}
-rpmdbMatchIterator rpmdbInitIterator(rpmdb db, int rpmtag,
+rpmdbMatchIterator rpmdbInitIterator(rpmdb db, rpmTag rpmtag,
const void * keyp, size_t keylen)
{
DBT * key = alloca(sizeof(*key));
+DBT * data = alloca(sizeof(*data));
rpmdbMatchIterator mi = NULL;
dbiIndexSet set = NULL;
dbiIndex dbi;
@@ -2169,12 +2215,11 @@ DBT * key = alloca(sizeof(*key));
if (db == NULL)
return NULL;
+
/* XXX HACK to remove rpmdbFindByLabel/findMatches from the API */
- switch (rpmtag) {
- case RPMDBI_LABEL:
+ if (rpmtag == RPMDBI_LABEL) {
rpmtag = RPMTAG_NAME;
isLabel = 1;
- break;
}
dbi = dbiOpen(db, rpmtag, 0);
@@ -2200,11 +2245,17 @@ DBT * key = alloca(sizeof(*key));
xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, 0);
memset(key, 0, sizeof(*key));
+/*@-temptrans@*/
key->data = (void *) keyp;
+/*@=temptrans@*/
key->size = keylen;
-if (key->size == 0) key->size = strlen((char *)key->data);
-if (key->size == 0) key->size++; /* XXX "/" fixup. */
- rc = dbiSearch(dbi, dbcursor, key, &set);
+if (key->data && key->size == 0) key->size = strlen((char *)key->data);
+if (key->data && key->size == 0) key->size++; /* XXX "/" fixup. */
+
+memset(data, 0, sizeof(*data));
+ rc = dbiSearch(dbi, dbcursor, key, data, DB_SET);
+if (rc == 0)
+xx = dbt2set(dbi, data, &set);
xx = dbiCclose(dbi, dbcursor, 0);
dbcursor = NULL;
@@ -2474,7 +2525,10 @@ if (key->size == 0) key->size = strlen((char *)key->data);
if (key->size == 0) key->size++; /* XXX "/" fixup. */
set = NULL;
- xx = dbiSearch(dbi, dbcursor, key, &set);
+memset(data, 0, sizeof(*data));
+ xx = dbiSearch(dbi, dbcursor, key, data, DB_SET);
+if (xx == 0)
+xx = dbt2set(dbi, data, &set);
if (xx < 0) /* not found */
xx = 0;
@@ -2484,8 +2538,13 @@ if (key->size == 0) key->size++; /* XXX "/" fixup. */
/*@-mods@*/ /* a single rec is not modified */
xx = dbiPruneSet(set, rec, 1, sizeof(*rec), 1);
/*@=mods@*/
- if (xx == 0 && dbiUpdateIndex(dbi, dbcursor, key, set))
- xx = 1;
+ if (xx == 0) {
+memset(data, 0, sizeof(*data));
+xx = set2dbt(dbi, data, set);
+ if (xx == 0 && dbiUpdateIndex(dbi, dbcursor, key, data, 0))
+ xx = 1;
+data->data = _free(data->data);
+ }
}
set = dbiFreeIndexSet(set);
@@ -2519,6 +2578,7 @@ if (key->size == 0) key->size++; /* XXX "/" fixup. */
int rpmdbAdd(rpmdb db, int iid, Header h)
{
DBT * key = alloca(sizeof(*key));
+DBT * data = alloca(sizeof(*data));
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
sigset_t signalMask;
@@ -2584,7 +2644,7 @@ DBT * key = alloca(sizeof(*key));
/*@i@*/ data->data = datap;
data->size = datalen;
/*@-compmempass@*/
- rc = dbiGet(dbi, dbcursor, key, data, 0);
+ rc = dbiGet(dbi, dbcursor, key, data, DB_SET);
/*@=compmempass@*/
keyp = key->data;
keylen = key->size;
@@ -2833,13 +2893,18 @@ DBT * key = alloca(sizeof(*key));
printed++;
}
memset(key, 0, sizeof(*key));
+/*@-observertrans@*/
key->data = (void *) valp;
+/*@=observertrans@*/
key->size = vallen;
if (key->size == 0) key->size = strlen((char *)key->data);
if (key->size == 0) key->size++; /* XXX "/" fixup. */
set = NULL;
- xx = dbiSearch(dbi, dbcursor, key, &set);
+memset(data, 0, sizeof(*data));
+ xx = dbiSearch(dbi, dbcursor, key, data, DB_SET);
+if (xx == 0)
+xx = dbt2set(dbi, data, &set);
if (xx > 0) { /* error */
xx = 1;
@@ -2856,8 +2921,11 @@ if (key->size == 0) key->size++; /* XXX "/" fixup. */
set = xcalloc(1, sizeof(*set));
}
(void) dbiAppendSet(set, rec, 1, sizeof(*rec), 0);
- if (dbiUpdateIndex(dbi, dbcursor, key, set))
- xx = 1;
+memset(data, 0, sizeof(*data));
+xx = set2dbt(dbi, data, set);
+ if (xx == 0 && dbiUpdateIndex(dbi, dbcursor, key, data, 0))
+ xx = 1;
+data->data = _free(data->data);
}
set = dbiFreeIndexSet(set);
rc += xx;
@@ -2906,11 +2974,17 @@ DBT * key = alloca(sizeof(*key));
/* Gather all matches from the database */
for (i = 0; i < numItems; i++) {
+
memset(key, 0, sizeof(*key));
+/*@-dependenttrans@*/
key->data = (void *) fpList[i].baseName;
+/*@=dependenttrans@*/
key->size = strlen((char *)key->data);
if (key->size == 0) key->size++; /* XXX "/" fixup. */
+
+ /*@-compmempass@*/
xx = rpmdbGrowIterator(mi, key, i);
+ /*@=compmempass@*/
matchList[i] = xcalloc(1, sizeof(*(matchList[i])));
}
@@ -3188,6 +3262,8 @@ static int rpmdbMoveDatabase(const char * prefix,
/*@-globs@*/ /* FIX: rpmGlobalMacroContext not in <rpmlib.h> */
int rpmdbRebuild(const char * prefix)
+ /*@globals _rebuildinprogress @*/
+ /*@modifies _rebuildinprogress @*/
{
rpmdb olddb;
const char * dbpath = NULL;
diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h
index 0dc0ad610..e07cc5a80 100644
--- a/rpmdb/rpmdb.h
+++ b/rpmdb/rpmdb.h
@@ -53,7 +53,7 @@ struct _dbiVec {
* @param rpmtag rpm tag
* @return 0 on success
*/
- int (*open) (rpmdb rpmdb, int rpmtag, /*@out@*/ dbiIndex * dbip)
+ int (*open) (rpmdb rpmdb, rpmTag rpmtag, /*@out@*/ dbiIndex * dbip)
/*@globals fileSystem@*/
/*@modifies *dbip, fileSystem @*/;
@@ -357,11 +357,11 @@ extern "C" {
/** \ingroup db3
* Return new configured index database handle instance.
* @param rpmdb rpm database
- * @param rpmtag
+ * @param rpmtag rpm tag
* @return index database handle
*/
/*@unused@*/ /*@only@*/ /*@null@*/
-dbiIndex db3New(rpmdb rpmdb, int rpmtag)
+dbiIndex db3New(rpmdb rpmdb, rpmTag rpmtag)
/*@globals rpmGlobalMacroContext @*/
/*@modifies rpmGlobalMacroContext @*/;
@@ -393,7 +393,7 @@ extern const char *const prDbiOpenFlags(int dbflags, int print_dbenv_flags)
* @param flags (unused)
* @return index database handle
*/
-/*@only@*/ /*@null@*/ dbiIndex dbiOpen(/*@null@*/ rpmdb db, int rpmtag,
+/*@only@*/ /*@null@*/ dbiIndex dbiOpen(/*@null@*/ rpmdb db, rpmTag rpmtag,
unsigned int flags)
/*@modifies db @*/;
@@ -464,7 +464,7 @@ int dbiGet(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
/*@globals fileSystem@*/
/*@modifies *dbcursor, *key, *data, fileSystem @*/
{
- assert(key->size > 0);
+ assert((flags == DB_NEXT) || key->size > 0);
return (dbi->dbi_vec->cget) (dbi, dbcursor, key, data, flags);
}
diff --git a/zlib/configure.in b/zlib/configure.in
index 7dd14408c..588f05198 100644
--- a/zlib/configure.in
+++ b/zlib/configure.in
@@ -6,7 +6,6 @@ AM_INIT_AUTOMAKE(zlib, 1.1.4)
dnl Check for programs.
AC_PROG_CC
-AM_DISABLE_SHARED
AC_PROG_LIBTOOL
CFLAGS="-DHAS_snprintf -DHAS_snprintf"