Bug 968520 - Add mozilla::fallible to FallibleTArray::AppendElements calls. r=froydnj

This commit is contained in:
Birunthan Mohanathas 2015-05-28 11:07:43 -07:00
parent fcc4ac1672
commit 470bd9148f
19 changed files with 35 additions and 29 deletions

View File

@ -409,7 +409,7 @@ NS_CreateJSTimeoutHandler(nsGlobalWindow *aWindow, Function& aFunction,
ErrorResult& aError)
{
FallibleTArray<JS::Heap<JS::Value> > args;
if (!args.AppendElements(aArguments)) {
if (!args.AppendElements(aArguments, fallible)) {
aError.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}

View File

@ -2005,7 +2005,7 @@ private:
if (!mKeyUsages.IsEmpty()) {
mJwk.mKey_ops.Construct();
if (!mJwk.mKey_ops.Value().AppendElements(mKeyUsages)) {
if (!mJwk.mKey_ops.Value().AppendElements(mKeyUsages, fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}

View File

@ -316,7 +316,8 @@ DataStoreDB::DatabaseOpened()
}
StringOrStringSequence objectStores;
if (!objectStores.RawSetAsStringSequence().AppendElements(mObjectStores)) {
if (!objectStores.RawSetAsStringSequence().AppendElements(mObjectStores,
fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}

View File

@ -20904,7 +20904,8 @@ VersionChangeOp::RunOnOwningThread()
MOZ_ASSERT(!info->mLiveDatabases.IsEmpty());
FallibleTArray<Database*> liveDatabases;
if (NS_WARN_IF(!liveDatabases.AppendElements(info->mLiveDatabases))) {
if (NS_WARN_IF(!liveDatabases.AppendElements(info->mLiveDatabases,
fallible))) {
deleteOp->SetFailureCode(NS_ERROR_OUT_OF_MEMORY);
} else {
#ifdef DEBUG

View File

@ -508,8 +508,8 @@ MediaRawData::MediaRawData(const uint8_t* aData, size_t aSize)
}
// We ensure sufficient capacity above so this shouldn't fail.
MOZ_ALWAYS_TRUE(mBuffer->AppendElements(aData, aSize));
MOZ_ALWAYS_TRUE(mBuffer->AppendElements(RAW_DATA_ALIGNMENT));
MOZ_ALWAYS_TRUE(mBuffer->AppendElements(aData, aSize, fallible));
MOZ_ALWAYS_TRUE(mBuffer->AppendElements(RAW_DATA_ALIGNMENT, fallible));
mSize = aSize;
}
@ -530,8 +530,8 @@ MediaRawData::Clone() const
}
// We ensure sufficient capacity above so this shouldn't fail.
MOZ_ALWAYS_TRUE(s->mBuffer->AppendElements(mData, mSize));
MOZ_ALWAYS_TRUE(s->mBuffer->AppendElements(RAW_DATA_ALIGNMENT));
MOZ_ALWAYS_TRUE(s->mBuffer->AppendElements(mData, mSize, fallible));
MOZ_ALWAYS_TRUE(s->mBuffer->AppendElements(RAW_DATA_ALIGNMENT, fallible));
s->mSize = mSize;
}
return s.forget();

View File

@ -113,7 +113,8 @@ uint32_t ResourceQueue::EvictBefore(uint64_t aOffset, ErrorResult& aRv)
evicted += offset;
nsRefPtr<MediaLargeByteBuffer> data = new MediaLargeByteBuffer;
if (!data->AppendElements(item->mData->Elements() + offset,
item->mData->Length() - offset)) {
item->mData->Length() - offset,
fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return 0;
}

View File

@ -566,7 +566,7 @@ SourceBuffer::PrepareAppend(const uint8_t* aData, uint32_t aLength, ErrorResult&
}
nsRefPtr<MediaLargeByteBuffer> data = new MediaLargeByteBuffer();
if (!data->AppendElements(aData, aLength)) {
if (!data->AppendElements(aData, aLength, fallible)) {
aRv.Throw(NS_ERROR_DOM_QUOTA_EXCEEDED_ERR);
return nullptr;
}

View File

@ -653,7 +653,8 @@ MobileMessageManager::DispatchTrustedDeletedEventToSelf(nsISupports* aDeletedInf
uint32_t msgIdLength = info->GetData().deletedMessageIds().Length();
if (msgIdLength) {
Sequence<int32_t>& deletedMsgIds = init.mDeletedMessageIds.SetValue();
if (!deletedMsgIds.AppendElements(info->GetData().deletedMessageIds())) {
if (!deletedMsgIds.AppendElements(info->GetData().deletedMessageIds(),
fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}
@ -661,7 +662,8 @@ MobileMessageManager::DispatchTrustedDeletedEventToSelf(nsISupports* aDeletedInf
uint32_t threadIdLength = info->GetData().deletedThreadIds().Length();
if (threadIdLength) {
Sequence<uint64_t>& deletedThreadIds = init.mDeletedThreadIds.SetValue();
if (!deletedThreadIds.AppendElements(info->GetData().deletedThreadIds())) {
if (!deletedThreadIds.AppendElements(info->GetData().deletedThreadIds(),
fallible)) {
return NS_ERROR_OUT_OF_MEMORY;
}
}

View File

@ -188,7 +188,7 @@ public:
MOZ_ASSERT(aWorkerPrivate);
aWorkerPrivate->AssertIsOnWorkerThread();
if (!mId.AppendElements(aId)) {
if (!mId.AppendElements(aId, fallible)) {
mRv.Throw(NS_ERROR_OUT_OF_MEMORY);
}
}

View File

@ -992,7 +992,7 @@ gfxFontUtils::RenameFont(const nsAString& aName, const uint8_t *aFontData,
uint32_t adjFontDataSize = paddedFontDataSize + nameTableSize;
// create new buffer: old font data plus new name table
if (!aNewFont->AppendElements(adjFontDataSize))
if (!aNewFont->AppendElements(adjFontDataSize, fallible))
return NS_ERROR_OUT_OF_MEMORY;
// copy the old font data

View File

@ -514,7 +514,7 @@ struct ParamTraits<FallibleTArray<E> >
return false;
}
E* elements = aResult->AppendElements(length);
E* elements = aResult->AppendElements(length, mozilla::fallible);
if (!elements) {
return false;
}

View File

@ -1502,7 +1502,7 @@ void BuildTextRunsScanner::FlushFrames(bool aFlushLineBreaks, bool aSuppressTrai
AutoFallibleTArray<uint8_t,BIG_TEXT_NODE_SIZE> buffer;
uint32_t bufferSize = mMaxTextLength*(mDoubleByteText ? 2 : 1);
if (bufferSize < mMaxTextLength || bufferSize == UINT32_MAX ||
!buffer.AppendElements(bufferSize)) {
!buffer.AppendElements(bufferSize, fallible)) {
return;
}
textRun = BuildTextRunForFrames(buffer.Elements());
@ -2050,7 +2050,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
// Need to expand the text. First transform it into a temporary buffer,
// then expand.
AutoFallibleTArray<uint8_t,BIG_TEXT_NODE_SIZE> tempBuf;
uint8_t* bufStart = tempBuf.AppendElements(contentLength);
uint8_t* bufStart = tempBuf.AppendElements(contentLength, fallible);
if (!bufStart) {
DestroyUserData(userDataToDestroy);
return nullptr;
@ -2268,7 +2268,7 @@ BuildTextRunsScanner::SetupLineBreakerContext(gfxTextRun *aTextRun)
if (bufferSize < mMaxTextLength || bufferSize == UINT32_MAX) {
return false;
}
void *textPtr = buffer.AppendElements(bufferSize);
void *textPtr = buffer.AppendElements(bufferSize, fallible);
if (!textPtr) {
return false;
}
@ -2341,7 +2341,7 @@ BuildTextRunsScanner::SetupLineBreakerContext(gfxTextRun *aTextRun)
// Need to expand the text. First transform it into a temporary buffer,
// then expand.
AutoFallibleTArray<uint8_t,BIG_TEXT_NODE_SIZE> tempBuf;
uint8_t* bufStart = tempBuf.AppendElements(contentLength);
uint8_t* bufStart = tempBuf.AppendElements(contentLength, fallible);
if (!bufStart) {
DestroyUserData(userDataToDestroy);
return false;
@ -5641,7 +5641,7 @@ nsTextFrame::PaintTextWithSelectionColors(gfxContext* aCtx,
// Figure out which selections control the colors to use for each character.
AutoFallibleTArray<SelectionDetails*,BIG_TEXT_NODE_SIZE> prevailingSelectionsBuffer;
SelectionDetails** prevailingSelections =
prevailingSelectionsBuffer.AppendElements(aContentLength);
prevailingSelectionsBuffer.AppendElements(aContentLength, fallible);
if (!prevailingSelections) {
return false;
}
@ -5781,7 +5781,7 @@ nsTextFrame::PaintTextSelectionDecorations(gfxContext* aCtx,
// Figure out which characters will be decorated for this selection.
AutoFallibleTArray<SelectionDetails*, BIG_TEXT_NODE_SIZE> selectedCharsBuffer;
SelectionDetails** selectedChars =
selectedCharsBuffer.AppendElements(aContentLength);
selectedCharsBuffer.AppendElements(aContentLength, fallible);
if (!selectedChars) {
return;
}
@ -7456,7 +7456,8 @@ nsTextFrame::AddInlineMinISizeForFlow(nsRenderingContext *aRenderingContext,
AutoFallibleTArray<bool,BIG_TEXT_NODE_SIZE> hyphBuffer;
bool *hyphBreakBefore = nullptr;
if (hyphenating) {
hyphBreakBefore = hyphBuffer.AppendElements(flowEndInTextRun - start);
hyphBreakBefore = hyphBuffer.AppendElements(flowEndInTextRun - start,
fallible);
if (hyphBreakBefore) {
provider.GetHyphenationBreaks(start, flowEndInTextRun - start,
hyphBreakBefore);

View File

@ -1544,7 +1544,7 @@ FontFaceSet::DispatchLoadingFinishedEvent(
init.mBubbles = false;
init.mCancelable = false;
OwningNonNull<FontFace>* elements =
init.mFontfaces.AppendElements(aFontFaces.Length());
init.mFontfaces.AppendElements(aFontFaces.Length(), fallible);
MOZ_ASSERT(elements);
for (size_t i = 0; i < aFontFaces.Length(); i++) {
elements[i] = aFontFaces[i];

View File

@ -66,7 +66,7 @@ BufferStream::DiscardBefore(int64_t aOffset)
bool
BufferStream::AppendBytes(const uint8_t* aData, size_t aLength)
{
return mData->AppendElements(aData, aLength);
return mData->AppendElements(aData, aLength, fallible);
}
MediaByteRange

View File

@ -662,7 +662,7 @@ WebrtcGlobalParent::RecvGetLogResult(const int& aRequestId,
CSFLogError(logTag, "Bad RequestId");
return false;
}
request->mResult.AppendElements(aLog);
request->mResult.AppendElements(aLog, fallible);
auto next = request->GetNextParent();
if (next) {

View File

@ -57,7 +57,7 @@ MemoryDownloader::ConsumeData(nsIInputStream* aIn,
uint32_t* aWriteCount)
{
MemoryDownloader* self = static_cast<MemoryDownloader*>(aClosure);
if (!self->mData->AppendElements(aFromRawSegment, aCount)) {
if (!self->mData->AppendElements(aFromRawSegment, aCount, fallible)) {
// The error returned by ConsumeData isn't propagated to the
// return of ReadSegments, so it has to be passed as state.
self->mStatus = NS_ERROR_OUT_OF_MEMORY;

View File

@ -674,7 +674,7 @@ nsUDPSocket::OnSocketReady(PRFileDesc *fd, int16_t outFlags)
SaveNetworkStats(false);
FallibleTArray<uint8_t> data;
if(!data.AppendElements(buff, count)){
if (!data.AppendElements(buff, count, fallible)) {
mCondition = NS_ERROR_UNEXPECTED;
return;
}

View File

@ -263,7 +263,7 @@ struct variant_storage_traits<uint8_t[], false>
{
_outData->Clear();
(void)_outData->AppendElements(static_cast<const uint8_t *>(aBlob.first),
aBlob.second);
aBlob.second, fallible);
}
static inline void destroy(const StorageType& _outData)
{ }

View File

@ -478,7 +478,7 @@ Merge(ChunkSet* aStoreChunks,
// to make the chunkranges continuous.
aStoreChunks->Merge(aUpdateChunks);
aStorePrefixes->AppendElements(adds);
aStorePrefixes->AppendElements(adds, fallible);
EntrySort(*aStorePrefixes);
return NS_OK;