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:
Douglas Crosher 2013-08-16 17:34:51 +10:00
parent aebcd36d9f
commit d92577ed59

View File

@ -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;
}