Bug 680556 - Make NS_(Re)Alloc infallible. r=bsmedberg

This commit is contained in:
Lucas Molas
2011-11-09 11:42:00 -05:00
parent e6874634fd
commit 005f11e59d

View File

@@ -192,29 +192,13 @@ nsMemoryImpl::sFlushEvent;
XPCOM_API(void*)
NS_Alloc(PRSize size)
{
if (size > PR_INT32_MAX)
return nsnull;
void* result = moz_malloc(size);
if (! result) {
// Request an asynchronous flush
sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), false);
}
return result;
return moz_xmalloc(size);
}
XPCOM_API(void*)
NS_Realloc(void* ptr, PRSize size)
{
if (size > PR_INT32_MAX)
return nsnull;
void* result = moz_realloc(ptr, size);
if (! result && size != 0) {
// Request an asynchronous flush
sGlobalMemory.FlushMemory(NS_LITERAL_STRING("alloc-failure").get(), false);
}
return result;
return moz_xrealloc(ptr, size);
}
XPCOM_API(void)