Bug 1037100 - Remove all use of ScopedDeleteArray from miscellaneous places. r=jcranmer

--HG--
extra : rebase_source : 937557b819742ee62e10a4afa6c5152b910cd8b2
This commit is contained in:
Jeff Walden 2014-07-10 20:37:40 -07:00
parent 29d704f6d4
commit 235c1f7500
4 changed files with 21 additions and 14 deletions

View File

@ -2,10 +2,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/UniquePtr.h"
#include "prerror.h"
#include "prprf.h"
#include "ScopedNSSTypes.h"
#include "nsNSSCertHelper.h"
#include "nsCOMPtr.h"
#include "nsNSSCertificate.h"
@ -813,7 +814,7 @@ ProcessRDN(CERTRDN* rdn, nsAString &finalString, nsINSSComponent *nssComponent)
// We know we can fit buffer of this length. CERT_RFC1485_EscapeAndQuote
// will fail if we provide smaller buffer then the result can fit to.
int escapedValueCapacity = decodeItem->len * 3 + 3;
ScopedDeleteArray<char> escapedValue(new char[escapedValueCapacity]);
UniquePtr<char[]> escapedValue = MakeUnique<char[]>(escapedValueCapacity);
SECStatus status = CERT_RFC1485_EscapeAndQuote(
escapedValue.get(),
@ -825,7 +826,7 @@ ProcessRDN(CERTRDN* rdn, nsAString &finalString, nsINSSComponent *nssComponent)
return NS_ERROR_FAILURE;
}
avavalue = NS_ConvertUTF8toUTF16(escapedValue);
avavalue = NS_ConvertUTF8toUTF16(escapedValue.get());
SECITEM_FreeItem(decodeItem, true);
params[0] = type.get();

View File

@ -24,11 +24,14 @@
#include "updatehelper.h"
#include "uachelper.h"
#include "pathhash.h"
#include "mozilla/Scoped.h"
#include "mozilla/UniquePtr.h"
// Needed for PathAppendW
#include <shlwapi.h>
using mozilla::MakeUnique;
using mozilla::UniquePtr;
WCHAR* MakeCommandLine(int argc, WCHAR **argv);
BOOL PathAppendSafe(LPWSTR base, LPCWSTR extra);
@ -233,7 +236,7 @@ StartServiceUpdate(LPCWSTR installDir)
// Get the service config information, in particular we want the binary
// path of the service.
mozilla::ScopedDeleteArray<char> serviceConfigBuffer(new char[bytesNeeded]);
UniquePtr<char[]> serviceConfigBuffer = MakeUnique<char[]>(bytesNeeded);
if (!QueryServiceConfigW(svc,
reinterpret_cast<QUERY_SERVICE_CONFIGW*>(serviceConfigBuffer.get()),
bytesNeeded, &bytesNeeded)) {

View File

@ -5,6 +5,7 @@
#include "NativeJSContainer.h"
#include "AndroidBridge.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/Vector.h"
#include "prthread.h"
#include "nsJSUtils.h"
@ -198,7 +199,8 @@ public:
return nullptr;
}
size_t newIndex = container->mRootedObjects.length();
PersistentObjectPtr rootedJSObject(new PersistentObject(cx, jsObject));
PersistentObjectPtr rootedJSObject =
MakeUnique<PersistentObject>(cx, jsObject);
if (!container->mRootedObjects.append(Move(rootedJSObject))) {
AndroidBridge::ThrowException(env,
"java/lang/OutOfMemoryError", "Cannot allocate object");
@ -233,7 +235,7 @@ public:
MOZ_ASSERT(mBuffer.data());
MOZ_ALWAYS_TRUE(mBuffer.read(mThreadContext, &value));
if (value.isObject()) {
mJSObject = new PersistentObject(mThreadContext, &value.toObject());
mJSObject = MakeUnique<PersistentObject>(mThreadContext, &value.toObject());
}
if (!mJSObject) {
AndroidBridge::ThrowException(env,
@ -281,7 +283,7 @@ private:
}
typedef JS::PersistentRooted<JSObject*> PersistentObject;
typedef ScopedDeletePtr<PersistentObject> PersistentObjectPtr;
typedef UniquePtr<PersistentObject> PersistentObjectPtr;
// Thread that the object is valid on
PRThread* mThread;
@ -443,7 +445,7 @@ struct PrimitiveProperty
static ArrayType NewArray(JNIEnv* env, jobject instance, JSContext* cx,
JS::HandleObject array, size_t length) {
ScopedDeleteArray<Type> buffer(new Type[length]);
UniquePtr<Type[]> buffer = MakeUnique<Type[]>(length);
for (size_t i = 0; i < length; i++) {
JS::RootedValue elem(cx);
if (!CheckJSCall(env, JS_GetElement(cx, array, i, &elem)) ||
@ -457,7 +459,7 @@ struct PrimitiveProperty
if (!jarray) {
return nullptr;
}
(env->*SetArrayRegionMethod)(jarray, 0, length, buffer);
(env->*SetArrayRegionMethod)(jarray, 0, length, buffer.get());
if (env->ExceptionCheck()) {
return nullptr;
}

View File

@ -25,7 +25,7 @@
#include "mozilla/Endian.h"
#include "mozilla/PodOperations.h"
#include "mozilla/Scoped.h"
#include "mozilla/UniquePtr.h"
#include "nsCRT.h"
#include "nsString.h"
@ -36,8 +36,9 @@
#include "jsfriendapi.h"
using mozilla::MakeUnique;
using mozilla::PodCopy;
using mozilla::ScopedDeleteArray;
using mozilla::UniquePtr;
NS_IMPL_ISUPPORTS(nsBinaryOutputStream,
nsIObjectOutputStream,
@ -846,7 +847,7 @@ nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength,
}
uint32_t bufSize = std::min<uint32_t>(aLength, 4096);
ScopedDeleteArray<char> buf(new char[bufSize]);
UniquePtr<char[]> buf = MakeUnique<char[]>(bufSize);
uint32_t remaining = aLength;
*rLength = 0;
@ -854,7 +855,7 @@ nsBinaryInputStream::ReadArrayBuffer(uint32_t aLength,
// Read data into temporary buffer.
uint32_t bytesRead;
uint32_t amount = std::min(remaining, bufSize);
nsresult rv = Read(buf, amount, &bytesRead);
nsresult rv = Read(buf.get(), amount, &bytesRead);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}