Fix sdallocx() assertion.
Refactor sdallocx() and nallocx() to share inallocx(), and fix an sdallocx() assertion to check usize rather than size.
This commit is contained in:
parent
d95e704fea
commit
a2260c95cd
@ -1838,19 +1838,29 @@ je_dallocx(void *ptr, int flags)
|
|||||||
ifree(ptr, try_tcache);
|
ifree(ptr, try_tcache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JEMALLOC_ALWAYS_INLINE_C size_t
|
||||||
|
inallocx(size_t size, int flags)
|
||||||
|
{
|
||||||
|
size_t usize;
|
||||||
|
|
||||||
|
if ((flags & MALLOCX_LG_ALIGN_MASK) == 0)
|
||||||
|
usize = s2u(size);
|
||||||
|
else
|
||||||
|
usize = sa2u(size, MALLOCX_ALIGN_GET_SPECIFIED(flags));
|
||||||
|
assert(usize != 0);
|
||||||
|
return (usize);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
je_sdallocx(void *ptr, size_t size, int flags)
|
je_sdallocx(void *ptr, size_t size, int flags)
|
||||||
{
|
{
|
||||||
bool try_tcache;
|
bool try_tcache;
|
||||||
|
size_t usize;
|
||||||
|
|
||||||
assert(ptr != NULL);
|
assert(ptr != NULL);
|
||||||
assert(malloc_initialized || IS_INITIALIZER);
|
assert(malloc_initialized || IS_INITIALIZER);
|
||||||
assert(size == isalloc(ptr, config_prof));
|
usize = inallocx(size, flags);
|
||||||
|
assert(usize == isalloc(ptr, config_prof));
|
||||||
if ((flags & MALLOCX_LG_ALIGN_MASK) == 0)
|
|
||||||
size = s2u(size);
|
|
||||||
else
|
|
||||||
size = sa2u(size, MALLOCX_ALIGN_GET_SPECIFIED(flags));
|
|
||||||
|
|
||||||
if ((flags & MALLOCX_ARENA_MASK) != 0) {
|
if ((flags & MALLOCX_ARENA_MASK) != 0) {
|
||||||
unsigned arena_ind = MALLOCX_ARENA_GET(flags);
|
unsigned arena_ind = MALLOCX_ARENA_GET(flags);
|
||||||
@ -1861,27 +1871,19 @@ je_sdallocx(void *ptr, size_t size, int flags)
|
|||||||
try_tcache = true;
|
try_tcache = true;
|
||||||
|
|
||||||
UTRACE(ptr, 0, 0);
|
UTRACE(ptr, 0, 0);
|
||||||
isfree(ptr, size, try_tcache);
|
isfree(ptr, usize, try_tcache);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
je_nallocx(size_t size, int flags)
|
je_nallocx(size_t size, int flags)
|
||||||
{
|
{
|
||||||
size_t usize;
|
|
||||||
|
|
||||||
assert(size != 0);
|
assert(size != 0);
|
||||||
|
|
||||||
if (malloc_init())
|
if (malloc_init())
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
if ((flags & MALLOCX_LG_ALIGN_MASK) == 0)
|
return (inallocx(size, flags));
|
||||||
usize = s2u(size);
|
|
||||||
else {
|
|
||||||
size_t alignment = MALLOCX_ALIGN_GET_SPECIFIED(flags);
|
|
||||||
usize = sa2u(size, alignment);
|
|
||||||
}
|
|
||||||
assert(usize != 0);
|
|
||||||
return (usize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user