mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 02:35:41 +00:00
Bug 871242 - Use js_malloc and js_realloc for the Sprinter to avoid the need for a JSContext. r=luke
This commit is contained in:
parent
aebcd36d9f
commit
d92577ed59
@ -721,9 +721,11 @@ bool
|
||||
Sprinter::realloc_(size_t newSize)
|
||||
{
|
||||
JS_ASSERT(newSize > (size_t) offset);
|
||||
char *newBuf = (char *) context->realloc_(base, newSize);
|
||||
if (!newBuf)
|
||||
char *newBuf = (char *) js_realloc(base, newSize);
|
||||
if (!newBuf) {
|
||||
reportOutOfMemory();
|
||||
return false;
|
||||
}
|
||||
base = newBuf;
|
||||
size = newSize;
|
||||
base[size - 1] = 0;
|
||||
@ -751,9 +753,11 @@ bool
|
||||
Sprinter::init()
|
||||
{
|
||||
JS_ASSERT(!initialized);
|
||||
base = (char *) context->malloc_(DefaultSize);
|
||||
if (!base)
|
||||
base = (char *) js_malloc(DefaultSize);
|
||||
if (!base) {
|
||||
reportOutOfMemory();
|
||||
return false;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
initialized = true;
|
||||
#endif
|
||||
@ -900,6 +904,7 @@ Sprinter::reportOutOfMemory()
|
||||
{
|
||||
if (reportedOOM)
|
||||
return;
|
||||
if (context)
|
||||
js_ReportOutOfMemory(context);
|
||||
reportedOOM = true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user