コード例 #1
0
ファイル: jscntxt.cpp プロジェクト: moussa1/mozilla-central
JSC::ExecutableAllocator *
ThreadData::createExecutableAllocator(JSContext *cx)
{
    JS_ASSERT(!execAlloc);
    JS_ASSERT(cx->runtime == rt);

    execAlloc = rt->new_<JSC::ExecutableAllocator>();
    if (!execAlloc)
        js_ReportOutOfMemory(cx);
    return execAlloc;
}
コード例 #2
0
ファイル: jscntxt.cpp プロジェクト: vingtetun/mozilla-central
RegExpPrivateCache *
ThreadData::createRegExpPrivateCache(JSContext *cx)
{
    JS_ASSERT(!repCache);
    JS_ASSERT(cx->runtime == rt);

    RegExpPrivateCache *newCache = rt->new_<RegExpPrivateCache>(rt);

    if (!newCache || !newCache->init()) {
        js_ReportOutOfMemory(cx);
        rt->delete_<RegExpPrivateCache>(newCache);
        return NULL;
    }

    repCache = newCache;
    return repCache;
}
コード例 #3
0
bool
XDRBuffer::grow(size_t n)
{
    JS_ASSERT(n > size_t(limit - cursor));
    
    const size_t MEM_BLOCK = 8192;
    size_t offset = cursor - base;
    size_t newCapacity = JS_ROUNDUP(offset + n, MEM_BLOCK);
    if (isUint32Overflow(newCapacity)) {
        JS_ReportErrorNumber(cx(), js_GetErrorMessage, NULL, JSMSG_TOO_BIG_TO_ENCODE);
        return false;
    }
        
    void *data = OffTheBooks::realloc_(base, newCapacity);
    if (!data) {
        js_ReportOutOfMemory(cx());
        return false;
    }
    base = static_cast<uint8_t *>(data);
    cursor = base + offset;
    limit = base + newCapacity;
    return true;
}