Date: Tue, 26 Apr 2016 01:17:05 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298600 - in head/lib/libc/db: btree hash Message-ID: <201604260117.u3Q1H5xB085083@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Tue Apr 26 01:17:05 2016 New Revision: 298600 URL: https://svnweb.freebsd.org/changeset/base/298600 Log: 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. Modified: head/lib/libc/db/btree/bt_open.c head/lib/libc/db/hash/hash.c Modified: head/lib/libc/db/btree/bt_open.c ============================================================================== --- head/lib/libc/db/btree/bt_open.c Tue Apr 26 00:29:00 2016 (r298599) +++ head/lib/libc/db/btree/bt_open.c Tue Apr 26 01:17:05 2016 (r298600) @@ -277,7 +277,7 @@ __bt_open(const char *fname, int flags, 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 Modified: head/lib/libc/db/hash/hash.c ============================================================================== --- head/lib/libc/db/hash/hash.c Tue Apr 26 00:29:00 2016 (r298599) +++ head/lib/libc/db/hash/hash.c Tue Apr 26 01:17:05 2016 (r298600) @@ -160,8 +160,7 @@ __hash_open(const char *file, int flags, * 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604260117.u3Q1H5xB085083>