aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-07-08 11:28:53 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2016-07-08 14:12:34 +0300
commit4aef6b36f862e46723403bc6422ac47058a5ef19 (patch)
treefa7afe6ed8f1abf080fa764bda1bbc81e07f407b /doc
parent260102cf7f75db3c87d04a06eb8054853cacce97 (diff)
downloadgdbm-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')
-rw-r--r--doc/gdbm.323
-rw-r--r--doc/gdbm.texi20
2 files changed, 29 insertions, 14 deletions
diff --git a/doc/gdbm.3 b/doc/gdbm.3
index 860829a..98b718b 100644
--- a/doc/gdbm.3
+++ b/doc/gdbm.3
@@ -1,5 +1,5 @@
1.\" This file is part of GDBM. 1.\" This file is part of GDBM.
2.\" Copyright (C) 2011, 2013 Free Software Foundation, Inc. 2.\" Copyright (C) 2011, 2013, 2016 Free Software Foundation, Inc.
3.\" 3.\"
4.\" GDBM is free software; you can redistribute it and/or modify 4.\" GDBM is free software; you can redistribute it and/or modify
5.\" it under the terms of the GNU General Public License as published by 5.\" it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
13.\" 13.\"
14.\" You should have received a copy of the GNU General Public License 14.\" You should have received a copy of the GNU General Public License
15.\" along with GDBM. If not, see <http://www.gnu.org/licenses/>. */ 15.\" along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
16.TH GDBM 3 "July 6, 2016" "GDBM" "GDBM User Reference" 16.TH GDBM 3 "July 8, 2016" "GDBM" "GDBM User Reference"
17.SH NAME 17.SH NAME
18GDBM \- The GNU database manager. Includes \fBdbm\fR and \fBndbm\fR 18GDBM \- The GNU database manager. Includes \fBdbm\fR and \fBndbm\fR
19compatibility. 19compatibility.
@@ -171,7 +171,7 @@ if it detects a fatal error. The only parameter of this function is a string.
171If the value of 0 is provided, \fBgdbm\fR will use a default function. 171If the value of 0 is provided, \fBgdbm\fR will use a default function.
172 172
173The return value is the pointer needed by all other routines to 173The return value is the pointer needed by all other routines to
174access that gdbm file. If the return is the NULL pointer, \fBgdbm_open\fR 174access that gdbm file. If the return is the \fBNULL\fR pointer, \fBgdbm_open\fR
175was not successful. The errors can be found in \fIgdbm_errno\fR for gdbm 175was not successful. The errors can be found in \fIgdbm_errno\fR for gdbm
176errors and in \fIerrno\fR for system errors. (For error codes, see 176errors and in \fIerrno\fR for system errors. (For error codes, see
177gdbmerrno.h.) 177gdbmerrno.h.)
@@ -218,8 +218,12 @@ To search for some data, use:
218\fIDbf\fR is the pointer returned by \fBgdbm_open\fR. \fIKey\fR is 218\fIDbf\fR is the pointer returned by \fBgdbm_open\fR. \fIKey\fR is
219the key data. 219the key data.
220 220
221If the \fIdptr\fR element of the return value is NULL, no data was 221If the \fIdptr\fR element of the return value is \fBNULL\fR, the
222found. Otherwise the return value is a pointer to the found data. 222\fBgdbm_errno\fR variable should be examined. The value of
223\fBGDBM_ITEM_NOT_FOUND\fR means no data was found for that \fIkey\fR.
224Other value means an error occurred.
225
226Otherwise the return value is a pointer to the found data.
223The storage space for the \fIdptr\fR element is allocated using 227The storage space for the \fIdptr\fR element is allocated using
224\fBmalloc(3)\fR. \fBGdbm\fI does not automatically free this data. 228\fBmalloc(3)\fR. \fBGdbm\fI does not automatically free this data.
225It is the programmer's responsibility to free this storage when it is 229It is the programmer's responsibility to free this storage when it is
@@ -259,8 +263,11 @@ the database once. (The order has to do with the hash values.)
259key data. 263key data.
260 264
261The return values are both of type \fBdatum\fR. If the \fIdptr\fR 265The return values are both of type \fBdatum\fR. If the \fIdptr\fR
262element of the return value is NULL, there is no first key or next key. 266element of the return value is \fBNULL\fR, inspect the
263Again notice that \fIdptr\fR points to data allocated by \fBmalloc(3)\fR 267\fBgdbm_errno\fR. If it is \fBGDBM_ITEM_NOT_FOUND\fR, there is no
268first key or next key. Otherwise, an error occurred.
269
270Again, notice that \fIdptr\fR points to data allocated by \fBmalloc(3)\fR
264and \fBgdbm\fR will not free it for you. 271and \fBgdbm\fR will not free it for you.
265 272
266These functions were intended to visit the database in read-only algorithms, 273These functions were intended to visit the database in read-only algorithms,
@@ -426,7 +433,7 @@ Send bug reports to <bug\-gdbm@gnu.org>.
426.SH AUTHORS 433.SH AUTHORS
427by Philip A. Nelson, Jason Downs and Sergey Poznyakoff. 434by Philip A. Nelson, Jason Downs and Sergey Poznyakoff.
428.SH COPYRIGHT 435.SH COPYRIGHT
429Copyright \(co 1990 - 2011 Free Software Foundation, Inc. 436Copyright \(co 1990 - 2016 Free Software Foundation, Inc.
430 437
431GDBM is free software; you can redistribute it and/or modify 438GDBM is free software; you can redistribute it and/or modify
432it under the terms of the GNU General Public License as published by 439it under the terms of the GNU General Public License as published by
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,
4351 Franklin Street, Fifth Floor 4351 Franklin Street, Fifth Floor
44Boston, MA 02110-1301, USA 44Boston, MA 02110-1301, USA
45 45
46Copyright @copyright{} 1989-1999, 2007-2011 Free Software Foundation, Inc. 46Copyright @copyright{} 1989-1999, 2007-2016 Free Software Foundation, Inc.
47 47
48Permission is granted to copy, distribute and/or modify this document 48Permission is granted to copy, distribute and/or modify this document
49under the terms of the GNU Free Documentation License, Version 1.3 or 49under 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
430memory block allocated by @code{malloc}. It is the caller's 430memory block allocated by @code{malloc}. It is the caller's
431responsibility to free it when no longer needed. 431responsibility to free it when no longer needed.
432 432
433If the @samp{dptr} is @samp{NULL}, no data was found. 433If the @samp{dptr} is @samp{NULL}, inspect the value of the
434@code{gdbm_errno} variable (@pxref{Variables,gdbm_errno}). If it is
435@samp{GDBM_ITEM_NOT_FOUND}, no data was found. Any other value means an
436error occurred. Use @code{gdbm_strerror} function to convert
437@code{gdbm_errno} to a human-readable string.
434 438
435The parameters are: 439The parameters are:
436 440
@@ -515,8 +519,10 @@ access is not @code{key} sequential, but it is guaranteed to visit every
515@deftypefn {gdbm interface} datum gdbm_firstkey (GDBM_FILE @var{dbf}) 519@deftypefn {gdbm interface} datum gdbm_firstkey (GDBM_FILE @var{dbf})
516Initiate sequential access to the database @var{dbf}. The returned 520Initiate sequential access to the database @var{dbf}. The returned
517value is the first key accessed in the database. If the @samp{dptr} 521value is the first key accessed in the database. If the @samp{dptr}
518field in the returned datum is @samp{NULL}, the database contains no 522field in the returned datum is @samp{NULL}, inspect the
519data. 523@code{gdbm_errno} variable (@pxref{Variables, gdbm_errno}). The value
524of @code{GDBM_ITEM_NOT_FOUND} means that the database contains no
525data. Other value means an error occurred.
520 526
521Otherwise, @samp{dptr} points to a memory block obtained from 527Otherwise, @samp{dptr} points to a memory block obtained from
522@code{malloc}, which holds the key value. The caller is responsible 528@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
530@code{gdbm_firstkey}. 536@code{gdbm_firstkey}.
531 537
532The function returns next key from the database. If the @samp{dptr} 538The function returns next key from the database. If the @samp{dptr}
533field in the returned datum is @samp{NULL}, all keys in the database 539field in the returned datum is @samp{NULL} inspect the
534has been visited. 540@code{gdbm_errno} variable (@pxref{Variables, gdbm_errno}). The value
541of @code{GDBM_ITEM_NOT_FOUND} means that all keys in the database
542has been visited. Any other value means an error occurred.
535 543
536Otherwise, @samp{dptr} points to a memory block obtained from 544Otherwise, @samp{dptr} points to a memory block obtained from
537@code{malloc}, which holds the key value. The caller is responsible 545@code{malloc}, which holds the key value. The caller is responsible

Return to:

Send suggestions and report system problems to the System administrator.