No bug - Fix OSX -Werror builds by initializing Chars::cx in the constructor; rs=Waldo over IRC

This commit is contained in:
Ms2ger 2011-11-01 22:46:48 +01:00
Родитель 0bcce1bfea
Коммит acb1ca198b
1 изменённых файлов: 4 добавлений и 5 удалений

Просмотреть файл

@ -616,14 +616,13 @@ class Chars {
JSContext *cx;
jschar *p;
public:
Chars() : p(NULL) {}
Chars(JSContext *cx) : cx(cx), p(NULL) {}
~Chars() { if (p) cx->free_(p); }
bool allocate(JSContext *cx, size_t len) {
bool allocate(size_t len) {
JS_ASSERT(!p);
// We're going to null-terminate!
p = (jschar *) cx->malloc_((len + 1) * sizeof(jschar));
this->cx = cx;
if (p) {
p[len] = jschar(0);
return true;
@ -642,8 +641,8 @@ JSStructuredCloneReader::readString(uint32_t nchars)
"string length");
return NULL;
}
Chars chars;
if (!chars.allocate(context(), nchars) || !in.readChars(chars.get(), nchars))
Chars chars(context());
if (!chars.allocate(nchars) || !in.readChars(chars.get(), nchars))
return NULL;
JSString *str = js_NewString(context(), chars.get(), nchars);
if (str)