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