summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-01-19 17:55:13 +0100
committerStefan Metzmacher <metze@samba.org>2011-01-20 05:31:43 +0100
commit9e00d2a9a47d03b41e88407eb89395b870a104a5 (patch)
tree9917732bf41f2c30bf7d56a45023ff6e4d7ed9c0
parentdf4752e3ab358d7f8312cec9caaaedf4f6e825a6 (diff)
downloadsamba-9e00d2a9a47d03b41e88407eb89395b870a104a5.tar.gz
samba-9e00d2a9a47d03b41e88407eb89395b870a104a5.tar.bz2
samba-9e00d2a9a47d03b41e88407eb89395b870a104a5.zip
lib/util: fix rounding to page size in allocate_anonymous_shared()
metze
-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 */