Simplify zone_good_size().
Simplify zone_good_size() to avoid memory allocation. Submitted by Mike Hommey.
This commit is contained in:
parent
7e15dab94d
commit
166a745b39
18
src/zone.c
18
src/zone.c
@ -133,22 +133,10 @@ zone_destroy(malloc_zone_t *zone)
|
|||||||
static size_t
|
static size_t
|
||||||
zone_good_size(malloc_zone_t *zone, size_t size)
|
zone_good_size(malloc_zone_t *zone, size_t size)
|
||||||
{
|
{
|
||||||
size_t ret;
|
|
||||||
void *p;
|
|
||||||
|
|
||||||
/*
|
if (size == 0)
|
||||||
* Actually create an object of the appropriate size, then find out
|
size = 1;
|
||||||
* how large it could have been without moving up to the next size
|
return (s2u(size));
|
||||||
* class.
|
|
||||||
*/
|
|
||||||
p = JEMALLOC_P(malloc)(size);
|
|
||||||
if (p != NULL) {
|
|
||||||
ret = isalloc(p);
|
|
||||||
JEMALLOC_P(free)(p);
|
|
||||||
} else
|
|
||||||
ret = size;
|
|
||||||
|
|
||||||
return (ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user