]> git.saurik.com Git - apple/libc.git/blame - db/hash/FreeBSD/ndbm.c.patch
Libc-391.2.10.tar.gz
[apple/libc.git] / db / hash / FreeBSD / ndbm.c.patch
CommitLineData
3d9156a7
A
1--- ndbm.c.orig 2004-10-28 23:25:13.000000000 -0700
2+++ ndbm.c 2004-10-28 23:25:42.000000000 -0700
59e0d9fe
A
3@@ -51,6 +51,7 @@
4 #include <string.h>
5 #include <errno.h>
6
7+#include <db.h>
8 #include <ndbm.h>
9 #include "hash.h"
10
11@@ -62,7 +63,8 @@
12 extern DBM *
13 dbm_open(file, flags, mode)
14 const char *file;
15- int flags, mode;
16+ int flags;
17+ mode_t mode;
18 {
19 HASHINFO info;
20 char path[MAXPATHLEN];
3d9156a7
A
21@@ -128,10 +130,14 @@
22 int status;
23 datum retkey;
24 DBT dbtretkey, dbtretdata;
25+ HTAB *htab = (HTAB *)(db->internal);
26
27 status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST);
28- if (status)
29+ if (status) {
30 dbtretkey.data = NULL;
31+ htab->nextkey_eof = 1;
32+ } else
33+ htab->nextkey_eof = 0;
34 retkey.dptr = dbtretkey.data;
35 retkey.dsize = dbtretkey.size;
36 return (retkey);
37@@ -146,13 +152,20 @@
38 dbm_nextkey(db)
39 DBM *db;
40 {
41- int status;
42+ int status = 1;
43 datum retkey;
44 DBT dbtretkey, dbtretdata;
45+ HTAB *htab = (HTAB *)(db->internal);
46
47- status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
48- if (status)
49+ if (htab->nextkey_eof)
50 dbtretkey.data = NULL;
51+ else {
52+ status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT);
53+ if (status) {
54+ dbtretkey.data = NULL;
55+ htab->nextkey_eof = 1;
56+ }
57+ }
58 retkey.dptr = dbtretkey.data;
59 retkey.dsize = dbtretkey.size;
60 return (retkey);