diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-08 11:28:53 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-08 14:12:34 +0300 |
commit | 4aef6b36f862e46723403bc6422ac47058a5ef19 (patch) | |
tree | fa7afe6ed8f1abf080fa764bda1bbc81e07f407b /doc/gdbm.texi | |
parent | 260102cf7f75db3c87d04a06eb8054853cacce97 (diff) | |
download | gdbm-4aef6b36f862e46723403bc6422ac47058a5ef19.tar.gz gdbm-4aef6b36f862e46723403bc6422ac47058a5ef19.tar.bz2 |
Fix error handling in gdbm_fetch, gdbm_firstkey, and gdbm_nextkey.
* src/gdbmfetch.c: Hanlde out of memory error.
* src/findkey.c: Set gdbm_errno to GDBM_ITEM_NOT_FOUND
if nothing was found.
* src/gdbmdelete.c: Don't set gdbm_errno after
_gdbm_findkey returns -1. It's been done already.
* src/gdbmexp.c (gdbm_export_to_file): Return -1 if
gdbm_fetch fails.
* src/gdbmseq.c (get_next_key): Set gdbm_errno to
GDBM_ITEM_NOT_FOUND if there's no next key.
Don't call _gdbm_fatal on out of memory condition.
(gdbm_nextkey): Set gdbm_errno to
GDBM_ITEM_NOT_FOUND if there's no next key.
* src/gdbmtool.c (fetch_handler)
(firstkey_handler,nextkey_handler): Check gdbm_errno.
* src/gdbmstore.c: Handle error return from _gdbm_findkey.
* tests/gtdump.c: Likewise.
* tests/gtfetch.c: Likewise.
* doc/gdbm.texi: Document changes.
* doc/gdbm.3: Likewise.
* configure.ac: Version 1.12.90
* NEWS: Update.
* .gitignore: Update.
Diffstat (limited to 'doc/gdbm.texi')
-rw-r--r-- | doc/gdbm.texi | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/doc/gdbm.texi b/doc/gdbm.texi index 6322a9b..6fad9d9 100644 --- a/doc/gdbm.texi +++ b/doc/gdbm.texi @@ -43,7 +43,7 @@ Published by the Free Software Foundation, 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA -Copyright @copyright{} 1989-1999, 2007-2011 Free Software Foundation, Inc. +Copyright @copyright{} 1989-1999, 2007-2016 Free Software Foundation, Inc. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -430,7 +430,11 @@ The @samp{dptr} field in the structure that is returned points to a memory block allocated by @code{malloc}. It is the caller's responsibility to free it when no longer needed. -If the @samp{dptr} is @samp{NULL}, no data was found. +If the @samp{dptr} is @samp{NULL}, inspect the value of the +@code{gdbm_errno} variable (@pxref{Variables,gdbm_errno}). If it is +@samp{GDBM_ITEM_NOT_FOUND}, no data was found. Any other value means an +error occurred. Use @code{gdbm_strerror} function to convert +@code{gdbm_errno} to a human-readable string. The parameters are: @@ -515,8 +519,10 @@ access is not @code{key} sequential, but it is guaranteed to visit every @deftypefn {gdbm interface} datum gdbm_firstkey (GDBM_FILE @var{dbf}) Initiate sequential access to the database @var{dbf}. The returned value is the first key accessed in the database. If the @samp{dptr} -field in the returned datum is @samp{NULL}, the database contains no -data. +field in the returned datum is @samp{NULL}, inspect the +@code{gdbm_errno} variable (@pxref{Variables, gdbm_errno}). The value +of @code{GDBM_ITEM_NOT_FOUND} means that the database contains no +data. Other value means an error occurred. Otherwise, @samp{dptr} points to a memory block obtained from @code{malloc}, which holds the key value. The caller is responsible @@ -530,8 +536,10 @@ value returned from a previous call to @code{gdbm_nextkey} or @code{gdbm_firstkey}. The function returns next key from the database. If the @samp{dptr} -field in the returned datum is @samp{NULL}, all keys in the database -has been visited. +field in the returned datum is @samp{NULL} inspect the +@code{gdbm_errno} variable (@pxref{Variables, gdbm_errno}). The value +of @code{GDBM_ITEM_NOT_FOUND} means that all keys in the database +has been visited. Any other value means an error occurred. Otherwise, @samp{dptr} points to a memory block obtained from @code{malloc}, which holds the key value. The caller is responsible |