No bug - Fix OSX -Werror builds by initializing Chars::cx in the constructor; rs=Waldo over IRC
authorMs2ger <ms2ger@gmail.com>
Tue, 01 Nov 2011 22:46:48 +0100
changeset 80193 3471b8810aad8361bfea1acf9365cb72d291a7b5
parent 80192 7cb178191144b0bd94260105fffc7efb3030465e
child 80194 971d806aa96e4d27fbd8612114fa9558e2d770e5
push id506
push userclegnitto@mozilla.com
push dateWed, 09 Nov 2011 02:03:18 +0000
treeherdermozilla-aurora@63587fc7bb93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
milestone10.0a1
No bug - Fix OSX -Werror builds by initializing Chars::cx in the constructor; rs=Waldo over IRC
js/src/jsclone.cpp
--- a/js/src/jsclone.cpp
+++ b/js/src/jsclone.cpp
@@ -611,24 +611,23 @@ JSStructuredCloneReader::checkDouble(jsd
     }
     return true;
 }
 
 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;
         }
         return false;
     }
     jschar *get() { return p; }
     void forget() { p = NULL; }
@@ -637,18 +636,18 @@ class Chars {
 JSString *
 JSStructuredCloneReader::readString(uint32_t nchars)
 {
     if (nchars > JSString::MAX_LENGTH) {
         JS_ReportErrorNumber(context(), js_GetErrorMessage, NULL, JSMSG_SC_BAD_SERIALIZED_DATA,
                              "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)
         chars.forget();
     return str;
 }
 
 bool