Bug 868725 - Pass non-const jschar* to AtomizeAndTakeOwnership; r=evilpie
authorMs2ger <ms2ger@gmail.com>
Sun, 05 May 2013 09:03:18 +0200
changeset 141793 ad75a1285e03ce7536866b37ce418d7e14398280
parent 141792 c34dd4b67355d1468f5911070270f9f046996b62
child 141794 c2df00e9434f0aea55030e357c08ab99e30cc9cb
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersevilpie
bugs868725
milestone23.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 868725 - Pass non-const jschar* to AtomizeAndTakeOwnership; r=evilpie
js/src/jsatom.cpp
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -229,47 +229,46 @@ enum OwnCharsBehavior
 
 /*
  * When the jschars reside in a freshly allocated buffer the memory can be used
  * as a new JSAtom's storage without copying. The contract is that the caller no
  * longer owns the memory and this method is responsible for freeing the memory.
  */
 JS_ALWAYS_INLINE
 static JSAtom *
-AtomizeAndTakeOwnership(JSContext *cx, const jschar *tbchars, size_t length,
-                           InternBehavior ib)
+AtomizeAndTakeOwnership(JSContext *cx, jschar *tbchars, size_t length, InternBehavior ib)
 {
     JS_ASSERT(tbchars[length] == 0);
 
     if (JSAtom *s = cx->runtime->staticStrings.lookup(tbchars, length)) {
-        js_free((void*)tbchars);
+        js_free(tbchars);
         return s;
     }
 
     /*
      * If a GC occurs at js_NewStringCopy then |p| will still have the correct
      * hash, allowing us to avoid rehashing it. Even though the hash is
      * unchanged, we need to re-lookup the table position because a last-ditch
      * GC will potentially free some table entries.
      */
     AtomSet& atoms = cx->runtime->atoms;
     AtomSet::AddPtr p = atoms.lookupForAdd(AtomHasher::Lookup(tbchars, length));
     SkipRoot skipHash(cx, &p); /* Prevent the hash from being poisoned. */
     if (p) {
         JSAtom *atom = p->asPtr();
         p->setTagged(bool(ib));
-        js_free((void*)tbchars);
+        js_free(tbchars);
         return atom;
     }
 
     AutoEnterAtomsCompartment ac(cx);
 
-    JSFlatString *flat = js_NewString<CanGC>(cx, const_cast<jschar*>(tbchars), length);
+    JSFlatString *flat = js_NewString<CanGC>(cx, tbchars, length);
     if (!flat) {
-        js_free((void*)tbchars);
+        js_free(tbchars);
         return NULL;
     }
 
     JSAtom *atom = flat->morphAtomizedStringIntoAtom();
 
     if (!atoms.relookupOrAdd(p, AtomHasher::Lookup(tbchars, length),
                              AtomStateEntry(atom, bool(ib)))) {
         JS_ReportOutOfMemory(cx); /* SystemAllocPolicy does not report OOM. */