diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-08 15:25:25 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-08 15:35:13 +0300 |
commit | 27b5d96eec6d43eed834c9f1492b1f3d38bf60ec (patch) | |
tree | ac20224e957ad7688ec31d03e6080c09ab9fc4c9 /src/gdbmexists.c | |
parent | 4aef6b36f862e46723403bc6422ac47058a5ef19 (diff) | |
download | gdbm-27b5d96eec6d43eed834c9f1492b1f3d38bf60ec.tar.gz gdbm-27b5d96eec6d43eed834c9f1492b1f3d38bf60ec.tar.bz2 |
Improve _gdbm_findkey interface.
* doc/gdbm.texi: Document gdbm_exists in detail.
* src/findkey.c (_gdbm_findkey): return parameters can be
NULL.
* src/gdbmexists.c (gdbm_exists): Remove unnecessary
local variables. Reset gdbm_errno to 0 if the key was
not found.
* src/gdbmdelete.c (gdbm_delete): Remove unnecessary
local variables.
* src/gdbmfetch.c: Likewise.
* src/gdbmseq.c: Likewise.
* src/gdbmstore.c: Likewise.
Diffstat (limited to 'src/gdbmexists.c')
-rw-r--r-- | src/gdbmexists.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/gdbmexists.c b/src/gdbmexists.c index c162037..9bbd308 100644 --- a/src/gdbmexists.c +++ b/src/gdbmexists.c @@ -27,8 +27,11 @@ int gdbm_exists (GDBM_FILE dbf, datum key) { - char *find_data; /* Dummy */ - int hash_val; /* Dummy */ - - return (_gdbm_findkey (dbf, key, &find_data, &hash_val) >= 0); + if (_gdbm_findkey (dbf, key, NULL, NULL) < 0) + { + if (gdbm_errno == GDBM_ITEM_NOT_FOUND) + gdbm_errno = GDBM_NO_ERROR; + return 0; + } + return 1; } |