b=566017; allow jemalloc posix_memalign to handle 0-sized allocs; r=jevans

This commit is contained in:
Benoit Jacob 2010-05-19 13:46:08 -07:00
parent e94d4e8f48
commit ca83ae7876

View File

@ -5829,6 +5829,19 @@ memalign(size_t alignment, size_t size)
goto RETURN;
}
if (size == 0) {
#ifdef MALLOC_SYSV
if (opt_sysv == false)
#endif
size = 1;
#ifdef MALLOC_SYSV
else {
ret = NULL;
goto RETURN;
}
#endif
}
alignment = alignment < sizeof(void*) ? sizeof(void*) : alignment;
ret = ipalloc(alignment, size);
@ -5863,6 +5876,8 @@ posix_memalign(void **memptr, size_t alignment, size_t size)
return (EINVAL);
}
/* The 0-->1 size promotion is done in the memalign() call below */
#ifdef MOZ_MEMORY_DARWIN
result = moz_memalign(alignment, size);
#else