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.
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 @@
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.
*/