summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorpst <pst@FreeBSD.org>1996-07-21 02:23:13 +0000
committerpst <pst@FreeBSD.org>1996-07-21 02:23:13 +0000
commitbcad0209e6c4cfa426c601e93ccdcdd5cb52ceef (patch)
treee7a75e01d90dc6baad0a38330b73930c4d8d396e /lib
parent62e961e1331841545c70e38dd3adad5a1c676adc (diff)
downloadFreeBSD-src-bcad0209e6c4cfa426c601e93ccdcdd5cb52ceef.zip
FreeBSD-src-bcad0209e6c4cfa426c601e93ccdcdd5cb52ceef.tar.gz
Bring in fixes to db 1.85 from NetBSD. These fixes have been documented as
being sent back to Bostic by the NetBSD crew. Obtained from: NetBSD-current
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/db/hash/hsearch.c2
-rw-r--r--lib/libc/db/hash/ndbm.c51
-rw-r--r--lib/libc/db/man/recno.34
3 files changed, 39 insertions, 18 deletions
diff --git a/lib/libc/db/hash/hsearch.c b/lib/libc/db/hash/hsearch.c
index cc8f7a4..6185330 100644
--- a/lib/libc/db/hash/hsearch.c
+++ b/lib/libc/db/hash/hsearch.c
@@ -62,7 +62,7 @@ hcreate(nel)
info.hash = NULL;
info.lorder = 0;
dbp = (DB *)__hash_open(NULL, O_CREAT | O_RDWR, 0600, &info, 0);
- return ((int)dbp);
+ return (dbp != NULL);
}
extern ENTRY *
diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c
index 28adce4..be6ff72 100644
--- a/lib/libc/db/hash/ndbm.c
+++ b/lib/libc/db/hash/ndbm.c
@@ -92,15 +92,20 @@ dbm_fetch(db, key)
DBM *db;
datum key;
{
- datum retval;
+ datum retdata;
int status;
+ DBT dbtkey, dbtretdata;
- status = (db->get)(db, (DBT *)&key, (DBT *)&retval, 0);
+ dbtkey.data = key.dptr;
+ dbtkey.size = key.dsize;
+ status = (db->get)(db, &dbtkey, &dbtretdata, 0);
if (status) {
- retval.dptr = NULL;
- retval.dsize = 0;
+ dbtretdata.data = NULL;
+ dbtretdata.size = 0;
}
- return (retval);
+ retdata.dptr = dbtretdata.data;
+ retdata.dsize = dbtretdata.size;
+ return (retdata);
}
/*
@@ -113,11 +118,14 @@ dbm_firstkey(db)
DBM *db;
{
int status;
- datum retdata, retkey;
+ datum retkey;
+ DBT dbtretkey, dbtretdata;
- status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_FIRST);
+ status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST);
if (status)
- retkey.dptr = NULL;
+ dbtretkey.data = NULL;
+ retkey.dptr = dbtretkey.data;
+ retkey.dsize = dbtretkey.size;
return (retkey);
}
@@ -131,13 +139,17 @@ dbm_nextkey(db)
DBM *db;
{
int status;
- datum retdata, retkey;
+ datum retkey;
+ DBT dbtretkey, dbtretdata;
- status = (db->seq)(db, (DBT *)&retkey, (DBT *)&retdata, R_NEXT);
+ status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
if (status)
- retkey.dptr = NULL;
+ dbtretkey.data = NULL;
+ retkey.dptr = dbtretkey.data;
+ retkey.dsize = dbtretkey.size;
return (retkey);
}
+
/*
* Returns:
* 0 on success
@@ -149,8 +161,11 @@ dbm_delete(db, key)
datum key;
{
int status;
+ DBT dbtkey;
- status = (db->del)(db, (DBT *)&key, 0);
+ dbtkey.data = key.dptr;
+ dbtkey.size = key.dsize;
+ status = (db->del)(db, &dbtkey, 0);
if (status)
return (-1);
else
@@ -164,12 +179,18 @@ dbm_delete(db, key)
* 1 if DBM_INSERT and entry exists
*/
extern int
-dbm_store(db, key, content, flags)
+dbm_store(db, key, data, flags)
DBM *db;
- datum key, content;
+ datum key, data;
int flags;
{
- return ((db->put)(db, (DBT *)&key, (DBT *)&content,
+ DBT dbtkey, dbtdata;
+
+ dbtkey.data = key.dptr;
+ dbtkey.size = key.dsize;
+ dbtdata.data = data.dptr;
+ dbtdata.size = data.dsize;
+ return ((db->put)(db, &dbtkey, &dbtdata,
(flags == DBM_INSERT) ? R_NOOVERWRITE : 0));
}
diff --git a/lib/libc/db/man/recno.3 b/lib/libc/db/man/recno.3
index 516bef0..bb5f353 100644
--- a/lib/libc/db/man/recno.3
+++ b/lib/libc/db/man/recno.3
@@ -204,10 +204,10 @@ or the following:
An attempt was made to add a record to a fixed-length database that
was too large to fit.
.SH "SEE ALSO"
-.IR btree (3)
+.IR btree (3),
.IR dbopen (3),
.IR hash (3),
-.IR mpool (3),
+.IR mpool (3)
.sp
.IR "Document Processing in a Relational Database System" ,
Michael Stonebraker, Heidi Stettner, Joseph Kalash, Antonin Guttman,
OpenPOWER on IntegriCloud