Bug 1219244 - use UniquePtr instead of nsAutoArrayPtr in dom/plugins/; r=aklotz

This commit is contained in:
Nathan Froyd 2015-10-28 09:44:19 -04:00
Родитель f1deeaf5dd
Коммит 99896ccf4b
4 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -23,6 +23,7 @@
#include "nsPluginsDirUtils.h"
#include "nsILocalFileMac.h"
#include "mozilla/UniquePtr.h"
#include "nsCocoaFeatures.h"
#if defined(MOZ_CRASHREPORTER)
@ -42,7 +43,6 @@
typedef NS_NPAPIPLUGIN_CALLBACK(const char *, NP_GETMIMEDESCRIPTION) ();
typedef NS_NPAPIPLUGIN_CALLBACK(OSErr, BP_GETSUPPORTEDMIMETYPES) (BPSupportedMIMETypes *mimeInfo, UInt32 flags);
/*
** Returns a CFBundleRef if the path refers to a Mac OS X bundle directory.
** The caller is responsible for calling CFRelease() to deallocate.
@ -238,16 +238,16 @@ static void ParsePlistPluginInfo(nsPluginInfo& info, CFBundleRef bundle)
memset(info.fMimeDescriptionArray, 0, mimeDataArraySize);
// Allocate memory for mime dictionary keys and values
nsAutoArrayPtr<CFTypeRef> keys(new CFTypeRef[mimeDictKeyCount]);
mozilla::UniquePtr<CFTypeRef[]> keys(new CFTypeRef[mimeDictKeyCount]);
if (!keys)
return;
nsAutoArrayPtr<CFTypeRef> values(new CFTypeRef[mimeDictKeyCount]);
mozilla::UniquePtr<CFTypeRef[]> values(new CFTypeRef[mimeDictKeyCount]);
if (!values)
return;
info.fVariantCount = 0;
::CFDictionaryGetKeysAndValues(mimeDict, keys, values);
::CFDictionaryGetKeysAndValues(mimeDict, keys.get(), values.get());
for (int i = 0; i < mimeDictKeyCount; i++) {
CFTypeRef mimeString = keys[i];
if (!mimeString || ::CFGetTypeID(mimeString) != ::CFStringGetTypeID()) {

Просмотреть файл

@ -9,6 +9,7 @@
#include "PluginInstanceParent.h"
#include "nsNPAPIPlugin.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/unused.h"
// How much data are we willing to send across the wire
@ -109,7 +110,7 @@ BrowserStreamParent::AnswerNPN_RequestRead(const IPCByteRanges& ranges,
if (ranges.Length() > INT32_MAX)
return false;
nsAutoArrayPtr<NPByteRange> rp(new NPByteRange[ranges.Length()]);
UniquePtr<NPByteRange[]> rp(new NPByteRange[ranges.Length()]);
for (uint32_t i = 0; i < ranges.Length(); ++i) {
rp[i].offset = ranges[i].offset;
rp[i].length = ranges[i].length;
@ -117,7 +118,7 @@ BrowserStreamParent::AnswerNPN_RequestRead(const IPCByteRanges& ranges,
}
rp[ranges.Length() - 1].next = nullptr;
*result = mNPP->mNPNIface->requestread(mStream, rp);
*result = mNPP->mNPNIface->requestread(mStream, rp.get());
return true;
}

Просмотреть файл

@ -33,6 +33,7 @@ using mozilla::gfx::SharedDIBSurface;
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/StaticPtr.h"
#include "mozilla/UniquePtr.h"
#include "ImageContainer.h"
using namespace mozilla;
@ -228,8 +229,8 @@ PluginInstanceChild::DoNPP_New()
NS_ASSERTION(argc == (int) mValues.Length(),
"argn.length != argv.length");
nsAutoArrayPtr<char*> argn(new char*[1 + argc]);
nsAutoArrayPtr<char*> argv(new char*[1 + argc]);
UniquePtr<char*[]> argn(new char*[1 + argc]);
UniquePtr<char*[]> argv(new char*[1 + argc]);
argn[argc] = 0;
argv[argc] = 0;
@ -241,7 +242,7 @@ PluginInstanceChild::DoNPP_New()
NPP npp = GetNPP();
NPError rv = mPluginIface->newp((char*)NullableStringGet(mMimeType), npp,
mMode, argc, argn, argv, 0);
mMode, argc, argn.get(), argv.get(), 0);
if (NPERR_NO_ERROR != rv) {
return rv;
}

Просмотреть файл

@ -12,6 +12,7 @@
#include "mozilla/ipc/MessageChannel.h"
#include "mozilla/ipc/CrossProcessMutex.h"
#include "mozilla/UniquePtr.h"
#include "gfxipc/ShadowLayerUtils.h"
#include "npapi.h"
@ -420,10 +421,10 @@ struct ParamTraits<NPString>
}
const char* messageBuffer = nullptr;
nsAutoArrayPtr<char> newBuffer(new char[byteCount]);
mozilla::UniquePtr<char[]> newBuffer(new char[byteCount]);
if (newBuffer && aMsg->ReadBytes(aIter, &messageBuffer, byteCount )) {
memcpy((void*)messageBuffer, newBuffer.get(), byteCount);
aResult->UTF8Characters = newBuffer.forget();
aResult->UTF8Characters = newBuffer.release();
return true;
}
}