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.
This commit is contained in:
Pedro F. Giffuni 2016-04-26 01:17:05 +00:00
parent 5d49c30c7b
commit 968c0b406d
2 changed files with 2 additions and 3 deletions

View File

@ -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

View File

@ -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