diff options
author | Jason Evans <je@fb.com> | 2012-02-29 20:56:37 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2012-02-29 20:56:37 (GMT) |
commit | 7e15dab94d3f008b0a6c296ad7afec9ed47ff1ac (patch) | |
tree | 3d1f5fe55bf7e48a26c645f2dd141d27b89703d2 /src | |
parent | 4bb09830133ffa8b27a95bc3727558007722c152 (diff) | |
download | jemalloc-7e15dab94d3f008b0a6c296ad7afec9ed47ff1ac.zip jemalloc-7e15dab94d3f008b0a6c296ad7afec9ed47ff1ac.tar.gz jemalloc-7e15dab94d3f008b0a6c296ad7afec9ed47ff1ac.tar.bz2 |
Add nallocm().
Add nallocm(), which computes the real allocation size that would result
from the corresponding allocm() call. nallocm() is a functional
superset of OS X's malloc_good_size(), in that it takes alignment
constraints into account.
Diffstat (limited to 'src')
-rw-r--r-- | src/jemalloc.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index ccc3a20..34fd1aa 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1586,6 +1586,28 @@ JEMALLOC_P(dallocm)(void *ptr, int flags) return (ALLOCM_SUCCESS); } +JEMALLOC_ATTR(visibility("default")) +int +JEMALLOC_P(nallocm)(size_t *rsize, size_t size, int flags) +{ + size_t usize; + size_t alignment = (ZU(1) << (flags & ALLOCM_LG_ALIGN_MASK) + & (SIZE_T_MAX-1)); + + assert(size != 0); + + if (malloc_init()) + return (ALLOCM_ERR_OOM); + + usize = (alignment == 0) ? s2u(size) : sa2u(size, alignment, NULL); + if (usize == 0) + return (ALLOCM_ERR_OOM); + + if (rsize != NULL) + *rsize = usize; + return (ALLOCM_SUCCESS); +} + /* * End non-standard functions. */ |