diff options
Diffstat (limited to 'src/common/OpenBSD_malloc_Linux.c')
-rw-r--r-- | src/common/OpenBSD_malloc_Linux.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common/OpenBSD_malloc_Linux.c b/src/common/OpenBSD_malloc_Linux.c index 59c2c7def1..da240c8e7e 100644 --- a/src/common/OpenBSD_malloc_Linux.c +++ b/src/common/OpenBSD_malloc_Linux.c @@ -1998,3 +1998,21 @@ void *valloc(size_t size) posix_memalign(&r, malloc_pagesize, size); return r; } + +size_t malloc_good_size(size_t size) +{ + if (size == 0) { + return 1; + } else if (size <= malloc_maxsize) { + int i, j; + /* round up to the nearest power of 2, with same approach + * as malloc_bytes() uses. */ + j = 1; + i = size - 1; + while (i >>= 1) + j++; + return ((size_t)1) << j; + } else { + return pageround(size); + } +} |