summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2012-02-29 20:58:39 (GMT)
committerJason Evans <je@fb.com>2012-02-29 21:03:29 (GMT)
commit166a745b395198c2b0d661caa717e6a9400291c6 (patch)
tree21eb28aa9f618fcb1748b4e43626956177ee0e89
parent7e15dab94d3f008b0a6c296ad7afec9ed47ff1ac (diff)
downloadjemalloc-166a745b395198c2b0d661caa717e6a9400291c6.zip
jemalloc-166a745b395198c2b0d661caa717e6a9400291c6.tar.gz
jemalloc-166a745b395198c2b0d661caa717e6a9400291c6.tar.bz2
Simplify zone_good_size().
Simplify zone_good_size() to avoid memory allocation. Submitted by Mike Hommey.
-rw-r--r--src/zone.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/src/zone.c b/src/zone.c
index 2c1b231..07f8861 100644
--- a/src/zone.c
+++ b/src/zone.c
@@ -133,22 +133,10 @@ zone_destroy(malloc_zone_t *zone)
static size_t
zone_good_size(malloc_zone_t *zone, size_t size)
{
- size_t ret;
- void *p;
- /*
- * Actually create an object of the appropriate size, then find out
- * how large it could have been without moving up to the next size
- * class.
- */
- p = JEMALLOC_P(malloc)(size);
- if (p != NULL) {
- ret = isalloc(p);
- JEMALLOC_P(free)(p);
- } else
- ret = size;
-
- return (ret);
+ if (size == 0)
+ size = 1;
+ return (s2u(size));
}
static void