summaryrefslogtreecommitdiffstats
path: root/lib/libc/db
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2016-04-26 01:17:05 +0000
committerpfg <pfg@FreeBSD.org>2016-04-26 01:17:05 +0000
commit4f3667123ffa7c2a0e85e234b34ef32232a438c0 (patch)
tree63eeeaa7b2ab85182e4e844e5332ad21cb2a615c /lib/libc/db
parentd814d9ecdead94fe209a5a59206fe6b17f920fcb (diff)
downloadFreeBSD-src-4f3667123ffa7c2a0e85e234b34ef32232a438c0.zip
FreeBSD-src-4f3667123ffa7c2a0e85e234b34ef32232a438c0.tar.gz
libc: make more use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read.
Diffstat (limited to 'lib/libc/db')
-rw-r--r--lib/libc/db/btree/bt_open.c2
-rw-r--r--lib/libc/db/hash/hash.c3
2 files changed, 2 insertions, 3 deletions
diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c
index 051fc28..640a669 100644
--- a/lib/libc/db/btree/bt_open.c
+++ b/lib/libc/db/btree/bt_open.c
@@ -277,7 +277,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int
b.cachesize = b.psize * MINCACHE;
/* Calculate number of pages to cache. */
- ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize;
+ ncache = howmany(b.cachesize, t->bt_psize);
/*
* The btree data structure requires that at least two keys can fit on
diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c
index f7b1427..c7dc4e7 100644
--- a/lib/libc/db/hash/hash.c
+++ b/lib/libc/db/hash/hash.c
@@ -160,8 +160,7 @@ __hash_open(const char *file, int flags, int mode,
* maximum bucket number, so the number of buckets is
* max_bucket + 1.
*/
- nsegs = (hashp->MAX_BUCKET + 1 + hashp->SGSIZE - 1) /
- hashp->SGSIZE;
+ nsegs = howmany(hashp->MAX_BUCKET + 1, hashp->SGSIZE);
if (alloc_segs(hashp, nsegs))
/*
* If alloc_segs fails, table will have been destroyed
OpenPOWER on IntegriCloud