mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1241901 part 4 - Stop using nsAutoPtr for holding primitive arrays. r=froydnj
This commit is contained in:
parent
f5a0c11137
commit
14908eadc8
@ -8,7 +8,7 @@
|
||||
|
||||
#include <mozilla/PodOperations.h>
|
||||
#include <mozilla/Assertions.h>
|
||||
#include <nsAutoPtr.h>
|
||||
#include <mozilla/UniquePtr.h>
|
||||
#include <AudioSampleFormat.h>
|
||||
|
||||
// Enable this to warn when `Output` has been called but not enough data was
|
||||
@ -62,8 +62,8 @@ public:
|
||||
// the exact right size in order to not waste space.
|
||||
uint32_t newLength = AvailableSamples() + inputSamples;
|
||||
uint32_t toCopy = AvailableSamples();
|
||||
nsAutoPtr<InputType> oldStorage = mStorage;
|
||||
mStorage = new InputType[newLength];
|
||||
UniquePtr<InputType[]> oldStorage = mozilla::Move(mStorage);
|
||||
mStorage = mozilla::MakeUnique<InputType[]>(newLength);
|
||||
// Copy the old data at the beginning of the new storage.
|
||||
if (WriteIndex() >= ReadIndex()) {
|
||||
PodCopy(mStorage.get(),
|
||||
@ -186,7 +186,7 @@ private:
|
||||
uint64_t mReadIndex;
|
||||
uint64_t mWriteIndex;
|
||||
// Storage for the samples
|
||||
nsAutoPtr<InputType> mStorage;
|
||||
mozilla::UniquePtr<InputType[]> mStorage;
|
||||
// Length of the buffer, in samples
|
||||
uint32_t mLength;
|
||||
};
|
||||
|
@ -640,10 +640,11 @@ nsPicoService::LoadEngine(PicoVoice* aVoice)
|
||||
}
|
||||
|
||||
if (!mPicoMemArea) {
|
||||
mPicoMemArea = new uint8_t[PICO_MEM_SIZE];
|
||||
mPicoMemArea = MakeUnique<uint8_t[]>(PICO_MEM_SIZE);
|
||||
}
|
||||
|
||||
status = sPicoApi.pico_initialize(mPicoMemArea, PICO_MEM_SIZE, &mPicoSystem);
|
||||
status = sPicoApi.pico_initialize(mPicoMemArea.get(),
|
||||
PICO_MEM_SIZE, &mPicoSystem);
|
||||
PICO_ENSURE_SUCCESS_VOID("pico_initialize", status);
|
||||
|
||||
status = sPicoApi.pico_loadResource(mPicoSystem, aVoice->mTaFile.get(), &mTaResource);
|
||||
|
@ -8,7 +8,6 @@
|
||||
#define nsPicoService_h
|
||||
|
||||
#include "mozilla/Mutex.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsTArray.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIThread.h"
|
||||
@ -16,6 +15,7 @@
|
||||
#include "nsRefPtrHashtable.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
#include "mozilla/Monitor.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
@ -82,7 +82,7 @@ private:
|
||||
|
||||
pico_Resource mTaResource;
|
||||
|
||||
nsAutoPtr<uint8_t> mPicoMemArea;
|
||||
mozilla::UniquePtr<uint8_t[]> mPicoMemArea;
|
||||
|
||||
static StaticRefPtr<nsPicoService> sSingleton;
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "base/message_pump.h"
|
||||
#include "base/time.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/UniquePtr.h"
|
||||
|
||||
// Declare structs we need from libevent.h rather than including it
|
||||
struct event_base;
|
||||
@ -192,7 +192,7 @@ public:
|
||||
mBufferSize(aBufferSize),
|
||||
mTerminator(aTerminator)
|
||||
{
|
||||
mReceiveBuffer = new char[mBufferSize];
|
||||
mReceiveBuffer = mozilla::MakeUnique<char[]>(mBufferSize);
|
||||
}
|
||||
|
||||
~LineWatcher() {}
|
||||
@ -208,7 +208,7 @@ protected:
|
||||
private:
|
||||
virtual void OnFileCanReadWithoutBlocking(int aFd) final override;
|
||||
|
||||
nsAutoPtr<char> mReceiveBuffer;
|
||||
mozilla::UniquePtr<char[]> mReceiveBuffer;
|
||||
int mReceivedIndex;
|
||||
int mBufferSize;
|
||||
char mTerminator;
|
||||
|
@ -32,6 +32,7 @@ using mozilla::plugins::PluginInstanceParent;
|
||||
#include "mozilla/gfx/DataSurfaceHelpers.h"
|
||||
#include "mozilla/gfx/Tools.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/UniquePtrExtensions.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "gfxContext.h"
|
||||
#include "prmem.h"
|
||||
@ -69,7 +70,7 @@ using namespace mozilla::plugins;
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
static nsAutoPtr<uint8_t> sSharedSurfaceData;
|
||||
static UniquePtr<uint8_t[]> sSharedSurfaceData;
|
||||
static IntSize sSharedSurfaceSize;
|
||||
|
||||
struct IconMetrics {
|
||||
@ -151,11 +152,11 @@ EnsureSharedSurfaceSize(IntSize size)
|
||||
|
||||
if (!sSharedSurfaceData || (WORDSSIZE(size) > WORDSSIZE(sSharedSurfaceSize))) {
|
||||
sSharedSurfaceSize = size;
|
||||
sSharedSurfaceData = nullptr;
|
||||
sSharedSurfaceData = (uint8_t *)malloc(WORDSSIZE(sSharedSurfaceSize) * 4);
|
||||
sSharedSurfaceData =
|
||||
MakeUniqueFallible<uint8_t[]>(WORDSSIZE(sSharedSurfaceSize) * 4);
|
||||
}
|
||||
|
||||
return (sSharedSurfaceData != nullptr);
|
||||
return !sSharedSurfaceData;
|
||||
}
|
||||
|
||||
nsIWidgetListener* nsWindow::GetPaintListener()
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "mozilla/RefPtr.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
|
||||
#include "nsCycleCollectionNoteChild.h"
|
||||
#include "mozilla/MemoryReporting.h"
|
||||
@ -21,6 +22,9 @@ template <class T>
|
||||
class nsAutoPtr
|
||||
{
|
||||
private:
|
||||
static_assert(!mozilla::IsScalar<T>::value, "If you are using "
|
||||
"nsAutoPtr to hold an array, use UniquePtr<T[]> instead");
|
||||
|
||||
void**
|
||||
begin_assignment()
|
||||
{
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "nsStreamUtils.h"
|
||||
#include "nsStringStream.h"
|
||||
#include "nsComponentManagerUtils.h"
|
||||
#include "nsAutoPtr.h"
|
||||
|
||||
TEST(CloneInputStream, InvalidInput)
|
||||
{
|
||||
@ -145,7 +144,7 @@ TEST(CloneInputStream, CloneMultiplexStream)
|
||||
testing::ConsumeAndValidateStream(clone, doubled);
|
||||
|
||||
// Stream that has been read should fail.
|
||||
nsAutoPtr<char> buffer(new char[512]);
|
||||
char buffer[512];
|
||||
uint32_t read;
|
||||
rv = stream->Read(buffer, 512, &read);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
@ -175,7 +174,7 @@ TEST(CloneInputStream, CloneMultiplexStreamPartial)
|
||||
}
|
||||
|
||||
// Fail when first stream read, but second hasn't been started.
|
||||
nsAutoPtr<char> buffer(new char[1024]);
|
||||
char buffer[1024];
|
||||
uint32_t read;
|
||||
nsresult rv = stream->Read(buffer, 1024, &read);
|
||||
ASSERT_TRUE(NS_SUCCEEDED(rv));
|
||||
|
Loading…
Reference in New Issue
Block a user