diff options
author | pst <pst@FreeBSD.org> | 1996-07-21 02:23:13 +0000 |
---|---|---|
committer | pst <pst@FreeBSD.org> | 1996-07-21 02:23:13 +0000 |
commit | bcad0209e6c4cfa426c601e93ccdcdd5cb52ceef (patch) | |
tree | e7a75e01d90dc6baad0a38330b73930c4d8d396e /lib/libc/db/hash | |
parent | 62e961e1331841545c70e38dd3adad5a1c676adc (diff) | |
download | FreeBSD-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/libc/db/hash')
-rw-r--r-- | lib/libc/db/hash/hsearch.c | 2 | ||||
-rw-r--r-- | lib/libc/db/hash/ndbm.c | 51 |
2 files changed, 37 insertions, 16 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)); } |