Bug 1071967 - Replace ScopedFreePtr with UniquePtr in jsapi.cpp. r=terrence

ScopedFreePtr is deprecated and uses |free| directly, as opposed to
UniquePtr, which can be made to use js_free.
This commit is contained in:
Guilherme Goncalves 2014-09-23 15:16:00 -04:00
parent 422aef5621
commit 6efaad6645

View File

@ -4476,15 +4476,15 @@ bool
JS::Compile(JSContext *cx, HandleObject obj, const ReadOnlyCompileOptions &options,
const char *bytes, size_t length, MutableHandleScript script)
{
mozilla::ScopedFreePtr<char16_t> chars;
mozilla::UniquePtr<char16_t, JS::FreePolicy> chars;
if (options.utf8)
chars = UTF8CharsToNewTwoByteCharsZ(cx, UTF8Chars(bytes, length), &length).get();
chars.reset(UTF8CharsToNewTwoByteCharsZ(cx, UTF8Chars(bytes, length), &length).get());
else
chars = InflateString(cx, bytes, &length);
chars.reset(InflateString(cx, bytes, &length));
if (!chars)
return false;
return Compile(cx, obj, options, chars, length, script);
return Compile(cx, obj, options, chars.get(), length, script);
}
bool
@ -4676,15 +4676,15 @@ JS::CompileFunction(JSContext *cx, HandleObject obj, const ReadOnlyCompileOption
const char *name, unsigned nargs, const char *const *argnames,
const char *bytes, size_t length, MutableHandleFunction fun)
{
mozilla::ScopedFreePtr<char16_t> chars;
mozilla::UniquePtr<char16_t, JS::FreePolicy> chars;
if (options.utf8)
chars = UTF8CharsToNewTwoByteCharsZ(cx, UTF8Chars(bytes, length), &length).get();
chars.reset(UTF8CharsToNewTwoByteCharsZ(cx, UTF8Chars(bytes, length), &length).get());
else
chars = InflateString(cx, bytes, &length);
chars.reset(InflateString(cx, bytes, &length));
if (!chars)
return false;
return CompileFunction(cx, obj, options, name, nargs, argnames, chars, length, fun);
return CompileFunction(cx, obj, options, name, nargs, argnames, chars.get(), length, fun);
}
JS_PUBLIC_API(bool)