mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Back out 6c435c96f10a (bug 736591) for Mac jsreftest orange
This commit is contained in:
parent
19334ee834
commit
bdbd325a96
@ -1688,6 +1688,22 @@ class RuntimeAllocPolicy
|
||||
void reportAllocOverflow() const {}
|
||||
};
|
||||
|
||||
/*
|
||||
* FIXME bug 647103 - replace these *AllocPolicy names.
|
||||
*/
|
||||
class ContextAllocPolicy
|
||||
{
|
||||
JSContext *const cx;
|
||||
|
||||
public:
|
||||
ContextAllocPolicy(JSContext *cx) : cx(cx) {}
|
||||
JSContext *context() const { return cx; }
|
||||
void *malloc_(size_t bytes) { return cx->malloc_(bytes); }
|
||||
void *realloc_(void *p, size_t oldBytes, size_t bytes) { return cx->realloc_(p, oldBytes, bytes); }
|
||||
void free_(void *p) { cx->free_(p); }
|
||||
void reportAllocOverflow() const { js_ReportAllocationOverflow(cx); }
|
||||
};
|
||||
|
||||
} /* namespace js */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -17,7 +17,6 @@ StringBuffer::extractWellSized()
|
||||
{
|
||||
size_t capacity = cb.capacity();
|
||||
size_t length = cb.length();
|
||||
JS_ASSERT(JSString::validateLength(context(), length));
|
||||
|
||||
jschar *buf = cb.extractRawBuffer();
|
||||
if (!buf)
|
||||
@ -47,7 +46,8 @@ StringBuffer::finishString()
|
||||
return cx->runtime->atomState.emptyAtom;
|
||||
|
||||
size_t length = cb.length();
|
||||
JS_ASSERT(JSString::validateLength(cx, length));
|
||||
if (!JSString::validateLength(cx, length))
|
||||
return NULL;
|
||||
|
||||
JS_STATIC_ASSERT(JSShortString::MAX_SHORT_LENGTH < CharBuffer::InlineLength);
|
||||
if (JSShortString::lengthFits(length))
|
||||
@ -72,8 +72,6 @@ StringBuffer::finishAtom()
|
||||
JSContext *cx = context();
|
||||
|
||||
size_t length = cb.length();
|
||||
JS_ASSERT(JSString::validateLength(cx, length));
|
||||
|
||||
if (length == 0)
|
||||
return cx->runtime->atomState.emptyAtom;
|
||||
|
||||
|
@ -29,28 +29,8 @@ namespace js {
|
||||
*/
|
||||
class StringBuffer
|
||||
{
|
||||
class AllocPolicy
|
||||
{
|
||||
JSContext *const cx;
|
||||
|
||||
public:
|
||||
AllocPolicy(JSContext *cx) : cx(cx) {}
|
||||
JSContext *context() const { return cx; }
|
||||
void *malloc_(size_t bytes) {
|
||||
if (!JSString::validateLength(cx, bytes / sizeof(jschar)))
|
||||
return NULL;
|
||||
return cx->malloc_(bytes);
|
||||
}
|
||||
void *realloc_(void *p, size_t oldBytes, size_t bytes) {
|
||||
if (!JSString::validateLength(cx, bytes / sizeof(jschar)))
|
||||
return NULL;
|
||||
return cx->realloc_(p, oldBytes, bytes);
|
||||
}
|
||||
void free_(void *p) { cx->free_(p); }
|
||||
void reportAllocOverflow() const { js_ReportAllocationOverflow(cx); }
|
||||
};
|
||||
|
||||
typedef Vector<jschar, 32, AllocPolicy> CharBuffer;
|
||||
/* cb's buffer is taken by the new string so use ContextAllocPolicy. */
|
||||
typedef Vector<jschar, 32, ContextAllocPolicy> CharBuffer;
|
||||
|
||||
CharBuffer cb;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user