summaryrefslogtreecommitdiffabout
path: root/src/gdbmcount.c
authorSergey Poznyakoff <gray@gnu.org>2020-03-15 15:32:42 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2020-03-15 15:32:42 (GMT)
commit02bc2dc9bee96c0e7d93d23c6f0b7a24d0e17566 (patch) (side-by-side diff)
tree61071105561260e4b08a8e3faee5f8a07645fc79 /src/gdbmcount.c
parent1f94a81a9f3a9955ca74dff07b7909595a850485 (diff)
downloadgdbm-newcache.tar.gz
gdbm-newcache.tar.bz2
Implement the gdbm_bucket_count function.newcache
* src/gdbmcount.c (gdbm_bucket_count): New function. * src/gdbm.h.in (gdbm_bucket_count): New proto. * doc/gdbm.texi: Document gdbm_bucket_count. * src/gdbmtool.c (bucket_count): Reimplement via gdbm_bucket_count.
Diffstat (limited to 'src/gdbmcount.c') (more/less context) (show whitespace changes)
-rw-r--r--src/gdbmcount.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/gdbmcount.c b/src/gdbmcount.c
index 4a78bc0..c81a461 100644
--- a/src/gdbmcount.c
+++ b/src/gdbmcount.c
@@ -40,3 +40,19 @@ gdbm_count (GDBM_FILE dbf, gdbm_count_t *pcount)
*pcount = count;
return 0;
}
+
+int
+gdbm_bucket_count (GDBM_FILE dbf, size_t *pcount)
+{
+ int i;
+ size_t count = 0;
+
+ GDBM_ASSERT_CONSISTENCY (dbf, -1);
+
+ for (i = 0; i < GDBM_DIR_COUNT (dbf); i = _gdbm_next_bucket_dir (dbf, i))
+ {
+ ++count;
+ }
+ *pcount = count;
+ return 0;
+}

Return to:

Send suggestions and report system problems to the System administrator.