mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1236571 - convert easy cases of nsAutoArrayPtr<T> to UniquePtr<T[]> in js/xpconnect/; r=gabor
The other cases are tied up with the startup cache, and will need more extensive refactoring.
This commit is contained in:
parent
86f5f14e8c
commit
30093940a4
@ -45,6 +45,7 @@
|
||||
#include "mozilla/MacroForEach.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::scache;
|
||||
@ -854,19 +855,19 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
|
||||
uint32_t len = (uint32_t)len64;
|
||||
|
||||
/* malloc an internal buf the size of the file */
|
||||
nsAutoArrayPtr<char> buf(new char[len + 1]);
|
||||
auto buf = MakeUniqueFallible<char[]>(len + 1);
|
||||
if (!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
/* read the file in one swoop */
|
||||
rv = scriptStream->Read(buf, len, &bytesRead);
|
||||
rv = scriptStream->Read(buf.get(), len, &bytesRead);
|
||||
if (bytesRead != len)
|
||||
return NS_BASE_STREAM_OSERROR;
|
||||
|
||||
buf[len] = '\0';
|
||||
|
||||
if (!mReuseLoaderGlobal) {
|
||||
Compile(cx, options, buf, bytesRead, &script);
|
||||
Compile(cx, options, buf.get(), bytesRead, &script);
|
||||
} else {
|
||||
// Note: exceptions will get handled further down;
|
||||
// don't early return for them here.
|
||||
@ -874,7 +875,7 @@ mozJSComponentLoader::ObjectForLocation(ComponentLoaderInfo& aInfo,
|
||||
if (scopeChain.append(obj)) {
|
||||
CompileFunction(cx, scopeChain,
|
||||
options, nullptr, 0, nullptr,
|
||||
buf, bytesRead, &function);
|
||||
buf.get(), bytesRead, &function);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/ProcessHangMonitor.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "AccessCheck.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsAboutProtocolUtils.h"
|
||||
@ -3249,11 +3250,11 @@ ReadSourceFromFilename(JSContext* cx, const char* filename, char16_t** src, size
|
||||
return NS_ERROR_FILE_TOO_BIG;
|
||||
|
||||
// Allocate an internal buf the size of the file.
|
||||
nsAutoArrayPtr<unsigned char> buf(new unsigned char[rawLen]);
|
||||
auto buf = MakeUniqueFallible<unsigned char>(rawLen);
|
||||
if (!buf)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
unsigned char* ptr = buf;
|
||||
unsigned char* ptr = buf.get();
|
||||
unsigned char* end = ptr + rawLen;
|
||||
while (ptr < end) {
|
||||
uint32_t bytesRead;
|
||||
@ -3264,7 +3265,7 @@ ReadSourceFromFilename(JSContext* cx, const char* filename, char16_t** src, size
|
||||
ptr += bytesRead;
|
||||
}
|
||||
|
||||
rv = nsScriptLoader::ConvertToUTF16(scriptChannel, buf, rawLen, EmptyString(),
|
||||
rv = nsScriptLoader::ConvertToUTF16(scriptChannel, buf.get(), rawLen, EmptyString(),
|
||||
nullptr, *src, *len);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user