diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-15 19:36:39 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-07-15 19:36:39 +0300 |
commit | 493772dc60886a315c749bf31fc1cbe682df5973 (patch) | |
tree | 9743f55e082e3306cf7ea3add00c152323afd065 /src/gdbmcount.c | |
parent | 44ca2b760b393e993b2a42fc489fa170910ad810 (diff) | |
download | gdbm-493772dc60886a315c749bf31fc1cbe682df5973.tar.gz gdbm-493772dc60886a315c749bf31fc1cbe682df5973.tar.bz2 |
New gdbm_setopt option to get the actual block size value
* src/gdbm.h.in (GDBM_GETBLOCKSIZE): New option.
* src/gdbmcount.c (gdbm_count): Fix memory leak on
error.
* src/gdbmsetopt.c (gdbm_setopt): Rewrite.
Handle GDBM_GETBLOCKSIZE.
* NEWS: Document GDBM_GETBLOCKSIZE
* doc/gdbm.texi: Likewise.
* tests/gtload.c: New options -bsexact and -verbose.
* tests/Makefile.am: Add new testcases.
* tests/testsuite.at: Likewise.
* tests/blocksize00.at: New testcase.
* tests/blocksize01.at: Likewise.
* tests/blocksize02.at: Likewise.
Diffstat (limited to 'src/gdbmcount.c')
-rw-r--r-- | src/gdbmcount.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/gdbmcount.c b/src/gdbmcount.c index a301d0c..861a708 100644 --- a/src/gdbmcount.c +++ b/src/gdbmcount.c @@ -39,7 +39,8 @@ gdbm_count (GDBM_FILE dbf, gdbm_count_t *pcount) off_t *sdir; gdbm_count_t count = 0; int i, last; - + int result; + /* Return immediately if the database needs recovery */ GDBM_ASSERT_CONSISTENCY (dbf, -1); @@ -53,17 +54,21 @@ gdbm_count (GDBM_FILE dbf, gdbm_count_t *pcount) memcpy (sdir, dbf->dir, dbf->header->dir_size); qsort (sdir, nbuckets, sizeof (off_t), compoff); + result = 0; for (i = last = 0; i < nbuckets; i++) { if (i == 0 || sdir[i] != sdir[last]) { if (_gdbm_read_bucket_at (dbf, sdir[i], &bucket, sizeof bucket)) - return -1; + { + result = -1; + break; + } count += bucket.count; last = i; } } free (sdir); *pcount = count; - return 0; + return result; } |