summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/util/util.c b/lib/util/util.c
index 42beed4bcb..8928026e80 100644
--- a/lib/util/util.c
+++ b/lib/util/util.c
@@ -941,10 +941,14 @@ void *allocate_anonymous_shared(size_t bufsz)
{
void *buf;
size_t pagesz = getpagesize();
+ size_t pagecnt;
+ /* round up to full pages */
+ pagecnt = bufsz / pagesz;
if (bufsz % pagesz) {
- bufsz = (bufsz + pagesz) % pagesz; /* round up to pagesz */
+ pagecnt += 1;
}
+ bufsz = pagesz * pagecnt;
#ifdef MAP_ANON
/* BSD */