diff options
author | 2002-02-12 17:19:41 +0000 | |
---|---|---|
committer | 2002-02-12 17:19:41 +0000 | |
commit | 38ceca31e3b4df3d1ecc27c06905af062057d818 (patch) | |
tree | 44d9416d4cf18da932071d8e2258fd1de0e37950 /sys/kern/kern_malloc.c | |
parent | beep! (diff) | |
download | wireguard-openbsd-38ceca31e3b4df3d1ecc27c06905af062057d818.tar.xz wireguard-openbsd-38ceca31e3b4df3d1ecc27c06905af062057d818.zip |
malloc_roundup to calculate allocation size malloc will use; from netbsd;
okay art@
Diffstat (limited to 'sys/kern/kern_malloc.c')
-rw-r--r-- | sys/kern/kern_malloc.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/sys/kern/kern_malloc.c b/sys/kern/kern_malloc.c index 01d3750929f..b2b58ea22e5 100644 --- a/sys/kern/kern_malloc.c +++ b/sys/kern/kern_malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_malloc.c,v 1.46 2002/01/16 20:50:17 miod Exp $ */ +/* $OpenBSD: kern_malloc.c,v 1.47 2002/02/12 17:19:41 provos Exp $ */ /* $NetBSD: kern_malloc.c,v 1.15.4.2 1996/06/13 17:10:56 cgd Exp $ */ /* @@ -598,3 +598,15 @@ sysctl_malloc(name, namelen, oldp, oldlenp, newp, newlen, p) } /* NOTREACHED */ } + +/* + * Round up a size to how much malloc would actually allocate. + */ +size_t +malloc_roundup(size_t sz) +{ + if (sz > MAXALLOCSAVE) + return round_page(sz); + + return (1 << BUCKETINDX(sz)); +} |