Bug 968520 - Add mozilla::fallible to Fallible{Auto,}TArray::SetLength calls. r=froydnj

This commit is contained in:
Birunthan Mohanathas 2015-05-18 13:50:35 -07:00
Родитель 0be91f1f80
Коммит 735ccdd101
40 изменённых файлов: 64 добавлений и 60 удалений

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

@ -376,7 +376,7 @@ WebGLElementArrayCacheTree<T>::Update(size_t firstByte, size_t lastByte)
// Step #0: If needed, resize our tree data storage. // Step #0: If needed, resize our tree data storage.
if (requiredNumLeaves != NumLeaves()) { if (requiredNumLeaves != NumLeaves()) {
// See class comment for why we the tree storage size is 2 * numLeaves. // See class comment for why we the tree storage size is 2 * numLeaves.
if (!mTreeData.SetLength(2 * requiredNumLeaves)) { if (!mTreeData.SetLength(2 * requiredNumLeaves, fallible)) {
mTreeData.SetLength(0); mTreeData.SetLength(0);
return false; return false;
} }
@ -470,7 +470,7 @@ bool
WebGLElementArrayCache::BufferData(const void* ptr, size_t byteLength) WebGLElementArrayCache::BufferData(const void* ptr, size_t byteLength)
{ {
if (mBytes.Length() != byteLength) { if (mBytes.Length() != byteLength) {
if (!mBytes.SetLength(byteLength)) { if (!mBytes.SetLength(byteLength, fallible)) {
mBytes.SetLength(0); mBytes.SetLength(0);
return false; return false;
} }

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

@ -152,7 +152,7 @@ ReadBuffer(JSStructuredCloneReader* aReader, CryptoBuffer& aBuffer)
} }
if (length > 0) { if (length > 0) {
if (!aBuffer.SetLength(length)) { if (!aBuffer.SetLength(length, fallible)) {
return false; return false;
} }
ret = JS_ReadBytes(aReader, aBuffer.Elements(), aBuffer.Length()); ret = JS_ReadBytes(aReader, aBuffer.Elements(), aBuffer.Length());

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

@ -555,7 +555,7 @@ private:
// Initialize the output buffer (enough space for padding / a full tag) // Initialize the output buffer (enough space for padding / a full tag)
uint32_t dataLen = mData.Length(); uint32_t dataLen = mData.Length();
uint32_t maxLen = dataLen + 16; uint32_t maxLen = dataLen + 16;
if (!mResult.SetLength(maxLen)) { if (!mResult.SetLength(maxLen, fallible)) {
return NS_ERROR_DOM_UNKNOWN_ERR; return NS_ERROR_DOM_UNKNOWN_ERR;
} }
uint32_t outLen = 0; uint32_t outLen = 0;
@ -679,7 +679,7 @@ private:
// Encrypt and return the wrapped key // Encrypt and return the wrapped key
// AES-KW encryption results in a wrapped key 64 bits longer // AES-KW encryption results in a wrapped key 64 bits longer
if (!mResult.SetLength(mData.Length() + 8)) { if (!mResult.SetLength(mData.Length() + 8, fallible)) {
return NS_ERROR_DOM_OPERATION_ERR; return NS_ERROR_DOM_OPERATION_ERR;
} }
SECItem resultItem = {siBuffer, mResult.Elements(), SECItem resultItem = {siBuffer, mResult.Elements(),
@ -811,7 +811,7 @@ private:
// Ciphertext is an integer mod the modulus, so it will be // Ciphertext is an integer mod the modulus, so it will be
// no longer than mStrength octets // no longer than mStrength octets
if (!mResult.SetLength(mStrength)) { if (!mResult.SetLength(mStrength, fallible)) {
return NS_ERROR_DOM_UNKNOWN_ERR; return NS_ERROR_DOM_UNKNOWN_ERR;
} }
@ -901,7 +901,7 @@ private:
virtual nsresult DoCrypto() override virtual nsresult DoCrypto() override
{ {
// Initialize the output buffer // Initialize the output buffer
if (!mResult.SetLength(HASH_LENGTH_MAX)) { if (!mResult.SetLength(HASH_LENGTH_MAX, fallible)) {
return NS_ERROR_DOM_UNKNOWN_ERR; return NS_ERROR_DOM_UNKNOWN_ERR;
} }
@ -1183,7 +1183,7 @@ private:
{ {
// Resize the result buffer // Resize the result buffer
uint32_t hashLen = HASH_ResultLenByOidTag(mOidTag); uint32_t hashLen = HASH_ResultLenByOidTag(mOidTag);
if (!mResult.SetLength(hashLen)) { if (!mResult.SetLength(hashLen, fallible)) {
return NS_ERROR_DOM_UNKNOWN_ERR; return NS_ERROR_DOM_UNKNOWN_ERR;
} }
@ -2597,7 +2597,7 @@ private:
return NS_ERROR_DOM_DATA_ERR; return NS_ERROR_DOM_DATA_ERR;
} }
if (!mResult.SetLength(mLength)) { if (!mResult.SetLength(mLength, fallible)) {
return NS_ERROR_DOM_UNKNOWN_ERR; return NS_ERROR_DOM_UNKNOWN_ERR;
} }
@ -2696,7 +2696,7 @@ private:
return NS_ERROR_DOM_DATA_ERR; return NS_ERROR_DOM_DATA_ERR;
} }
if (!mResult.SetLength(mLength)) { if (!mResult.SetLength(mLength, fallible)) {
return NS_ERROR_DOM_UNKNOWN_ERR; return NS_ERROR_DOM_UNKNOWN_ERR;
} }

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

@ -15771,7 +15771,7 @@ DatabaseOperationBase::GetStructuredCloneReadInfoFromBlob(
} }
AutoFallibleTArray<uint8_t, 512> uncompressed; AutoFallibleTArray<uint8_t, 512> uncompressed;
if (NS_WARN_IF(!uncompressed.SetLength(uncompressedLength))) { if (NS_WARN_IF(!uncompressed.SetLength(uncompressedLength, fallible))) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
@ -21756,7 +21756,8 @@ ObjectStoreGetRequestOp::GetResponse(RequestResponse& aResponse)
if (!mResponse.IsEmpty()) { if (!mResponse.IsEmpty()) {
FallibleTArray<SerializedStructuredCloneReadInfo> fallibleCloneInfos; FallibleTArray<SerializedStructuredCloneReadInfo> fallibleCloneInfos;
if (NS_WARN_IF(!fallibleCloneInfos.SetLength(mResponse.Length()))) { if (NS_WARN_IF(!fallibleCloneInfos.SetLength(mResponse.Length(),
fallible))) {
aResponse = NS_ERROR_OUT_OF_MEMORY; aResponse = NS_ERROR_OUT_OF_MEMORY;
return; return;
} }
@ -22304,7 +22305,8 @@ IndexGetRequestOp::GetResponse(RequestResponse& aResponse)
if (!mResponse.IsEmpty()) { if (!mResponse.IsEmpty()) {
FallibleTArray<SerializedStructuredCloneReadInfo> fallibleCloneInfos; FallibleTArray<SerializedStructuredCloneReadInfo> fallibleCloneInfos;
if (NS_WARN_IF(!fallibleCloneInfos.SetLength(mResponse.Length()))) { if (NS_WARN_IF(!fallibleCloneInfos.SetLength(mResponse.Length(),
fallible))) {
aResponse = NS_ERROR_OUT_OF_MEMORY; aResponse = NS_ERROR_OUT_OF_MEMORY;
return; return;
} }

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

@ -1178,7 +1178,8 @@ IDBObjectStore::AddOrPut(JSContext* aCx,
} }
FallibleTArray<uint8_t> cloneData; FallibleTArray<uint8_t> cloneData;
if (NS_WARN_IF(!cloneData.SetLength(cloneWriteInfo.mCloneBuffer.nbytes()))) { if (NS_WARN_IF(!cloneData.SetLength(cloneWriteInfo.mCloneBuffer.nbytes(),
fallible))) {
aRv = NS_ERROR_OUT_OF_MEMORY; aRv = NS_ERROR_OUT_OF_MEMORY;
return nullptr; return nullptr;
} }

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

@ -968,7 +968,7 @@ CreateBlobImpl(const nsTArray<BlobData>& aBlobDatas,
} }
FallibleTArray<nsRefPtr<BlobImpl>> fallibleBlobImpls; FallibleTArray<nsRefPtr<BlobImpl>> fallibleBlobImpls;
if (NS_WARN_IF(!fallibleBlobImpls.SetLength(aBlobDatas.Length()))) { if (NS_WARN_IF(!fallibleBlobImpls.SetLength(aBlobDatas.Length(), fallible))) {
return nullptr; return nullptr;
} }

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

@ -625,7 +625,8 @@ MediaRawDataWriter::SetSize(size_t aSize)
// Pad our buffer. We ensure sufficient capacity above so this shouldn't fail. // Pad our buffer. We ensure sufficient capacity above so this shouldn't fail.
MOZ_ALWAYS_TRUE( MOZ_ALWAYS_TRUE(
mBuffer->SetLength(aSize + mTarget->mPadding + RAW_DATA_ALIGNMENT)); mBuffer->SetLength(aSize + mTarget->mPadding + RAW_DATA_ALIGNMENT,
fallible));
mTarget->mSize = mSize = aSize; mTarget->mSize = mSize = aSize;
return true; return true;
} }

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

@ -35,7 +35,7 @@ MP4Demuxer::Init()
return InitPromise::CreateAndReject(DemuxerFailureReason::WAITING_FOR_DATA, __func__); return InitPromise::CreateAndReject(DemuxerFailureReason::WAITING_FOR_DATA, __func__);
} }
if (!mInitData->SetLength(br.Length())) { if (!mInitData->SetLength(br.Length(), fallible)) {
// OOM // OOM
return InitPromise::CreateAndReject(DemuxerFailureReason::DEMUXER_ERROR, __func__); return InitPromise::CreateAndReject(DemuxerFailureReason::DEMUXER_ERROR, __func__);
} }

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

@ -175,7 +175,7 @@ public:
if (initSegment || !HasCompleteInitData()) { if (initSegment || !HasCompleteInitData()) {
if (mParser.mInitEndOffset > 0) { if (mParser.mInitEndOffset > 0) {
MOZ_ASSERT(mParser.mInitEndOffset <= mResource->GetLength()); MOZ_ASSERT(mParser.mInitEndOffset <= mResource->GetLength());
if (!mInitData->SetLength(mParser.mInitEndOffset)) { if (!mInitData->SetLength(mParser.mInitEndOffset, fallible)) {
// Super unlikely OOM // Super unlikely OOM
return false; return false;
} }
@ -306,7 +306,7 @@ public:
const MediaByteRange& range = mParser->mInitRange; const MediaByteRange& range = mParser->mInitRange;
uint32_t length = range.mEnd - range.mStart; uint32_t length = range.mEnd - range.mStart;
if (length) { if (length) {
if (!mInitData->SetLength(length)) { if (!mInitData->SetLength(length, fallible)) {
// Super unlikely OOM // Super unlikely OOM
return false; return false;
} }

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

@ -62,7 +62,7 @@ public:
// These allocations might fail if content provides a huge number of // These allocations might fail if content provides a huge number of
// channels or size, but it's OK since we'll deal with the failure // channels or size, but it's OK since we'll deal with the failure
// gracefully. // gracefully.
if (mInputChannels.SetLength(mNumberOfChannels)) { if (mInputChannels.SetLength(mNumberOfChannels, fallible)) {
for (uint32_t i = 0; i < mNumberOfChannels; ++i) { for (uint32_t i = 0; i < mNumberOfChannels; ++i) {
mInputChannels[i] = new (fallible) float[mLength]; mInputChannels[i] = new (fallible) float[mLength];
if (!mInputChannels[i]) { if (!mInputChannels[i]) {

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

@ -196,7 +196,7 @@ DelayBuffer::EnsureBuffer()
// block size, so that no block of writes will need to wrap. // block size, so that no block of writes will need to wrap.
const int chunkCount = (mMaxDelayTicks + 2 * WEBAUDIO_BLOCK_SIZE - 1) >> const int chunkCount = (mMaxDelayTicks + 2 * WEBAUDIO_BLOCK_SIZE - 1) >>
WEBAUDIO_BLOCK_SIZE_BITS; WEBAUDIO_BLOCK_SIZE_BITS;
if (!mChunks.SetLength(chunkCount)) { if (!mChunks.SetLength(chunkCount, fallible)) {
return false; return false;
} }

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

@ -352,7 +352,7 @@ MediaDecodeTask::FinishDecode()
// write fewer bytes than mResampledFrames to the output buffer, in which // write fewer bytes than mResampledFrames to the output buffer, in which
// case mWriteIndex will tell us how many valid samples we have. // case mWriteIndex will tell us how many valid samples we have.
bool memoryAllocationSuccess = true; bool memoryAllocationSuccess = true;
if (!mDecodeJob.mChannelBuffers.SetLength(channelCount)) { if (!mDecodeJob.mChannelBuffers.SetLength(channelCount, fallible)) {
memoryAllocationSuccess = false; memoryAllocationSuccess = false;
} else { } else {
for (uint32_t i = 0; i < channelCount; ++i) { for (uint32_t i = 0; i < channelCount; ++i) {

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

@ -356,7 +356,7 @@ MobileMessageManager::Delete(const Sequence<OwningLongOrMozSmsMessageOrMozMmsMes
{ {
const uint32_t size = aParams.Length(); const uint32_t size = aParams.Length();
FallibleTArray<int32_t> idArray; FallibleTArray<int32_t> idArray;
if (!idArray.SetLength(size)) { if (!idArray.SetLength(size, fallible)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY); aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr; return nullptr;
} }

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

@ -778,7 +778,7 @@ PluginScriptableObjectChild::AnswerInvoke(const PluginIdentifier& aId,
AutoFallibleTArray<NPVariant, 10> convertedArgs; AutoFallibleTArray<NPVariant, 10> convertedArgs;
uint32_t argCount = aArgs.Length(); uint32_t argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount, mozilla::fallible)) {
*aResult = void_t(); *aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
@ -848,7 +848,7 @@ PluginScriptableObjectChild::AnswerInvokeDefault(InfallibleTArray<Variant>&& aAr
AutoFallibleTArray<NPVariant, 10> convertedArgs; AutoFallibleTArray<NPVariant, 10> convertedArgs;
uint32_t argCount = aArgs.Length(); uint32_t argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount, mozilla::fallible)) {
*aResult = void_t(); *aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
@ -1099,7 +1099,7 @@ PluginScriptableObjectChild::AnswerConstruct(InfallibleTArray<Variant>&& aArgs,
AutoFallibleTArray<NPVariant, 10> convertedArgs; AutoFallibleTArray<NPVariant, 10> convertedArgs;
uint32_t argCount = aArgs.Length(); uint32_t argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount, mozilla::fallible)) {
*aResult = void_t(); *aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;

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

@ -824,7 +824,7 @@ PluginScriptableObjectParent::AnswerInvoke(const PluginIdentifier& aId,
AutoFallibleTArray<NPVariant, 10> convertedArgs; AutoFallibleTArray<NPVariant, 10> convertedArgs;
uint32_t argCount = aArgs.Length(); uint32_t argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount, fallible)) {
*aResult = void_t(); *aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
@ -907,7 +907,7 @@ PluginScriptableObjectParent::AnswerInvokeDefault(InfallibleTArray<Variant>&& aA
AutoFallibleTArray<NPVariant, 10> convertedArgs; AutoFallibleTArray<NPVariant, 10> convertedArgs;
uint32_t argCount = aArgs.Length(); uint32_t argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount, fallible)) {
*aResult = void_t(); *aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;
@ -1227,7 +1227,7 @@ PluginScriptableObjectParent::AnswerConstruct(InfallibleTArray<Variant>&& aArgs,
AutoFallibleTArray<NPVariant, 10> convertedArgs; AutoFallibleTArray<NPVariant, 10> convertedArgs;
uint32_t argCount = aArgs.Length(); uint32_t argCount = aArgs.Length();
if (!convertedArgs.SetLength(argCount)) { if (!convertedArgs.SetLength(argCount, fallible)) {
*aResult = void_t(); *aResult = void_t();
*aSuccess = false; *aSuccess = false;
return true; return true;

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

@ -131,7 +131,7 @@ DOMSVGLengthList::InternalListLengthWillChange(uint32_t aNewLength)
} }
} }
if (!mItems.SetLength(aNewLength)) { if (!mItems.SetLength(aNewLength, fallible)) {
// We silently ignore SetLength OOM failure since being out of sync is safe // We silently ignore SetLength OOM failure since being out of sync is safe
// so long as we have *fewer* items than our internal list. // so long as we have *fewer* items than our internal list.
mItems.Clear(); mItems.Clear();

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

@ -132,7 +132,7 @@ DOMSVGNumberList::InternalListLengthWillChange(uint32_t aNewLength)
} }
} }
if (!mItems.SetLength(aNewLength)) { if (!mItems.SetLength(aNewLength, fallible)) {
// We silently ignore SetLength OOM failure since being out of sync is safe // We silently ignore SetLength OOM failure since being out of sync is safe
// so long as we have *fewer* items than our internal list. // so long as we have *fewer* items than our internal list.
mItems.Clear(); mItems.Clear();

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

@ -166,7 +166,7 @@ DOMSVGPointList::InternalListWillChangeTo(const SVGPointList& aNewValue)
} }
} }
if (!mItems.SetLength(newLength)) { if (!mItems.SetLength(newLength, fallible)) {
// We silently ignore SetLength OOM failure since being out of sync is safe // We silently ignore SetLength OOM failure since being out of sync is safe
// so long as we have *fewer* items than our internal list. // so long as we have *fewer* items than our internal list.
mItems.Clear(); mItems.Clear();

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

@ -132,7 +132,7 @@ DOMSVGTransformList::InternalListLengthWillChange(uint32_t aNewLength)
} }
} }
if (!mItems.SetLength(aNewLength)) { if (!mItems.SetLength(aNewLength, fallible)) {
// We silently ignore SetLength OOM failure since being out of sync is safe // We silently ignore SetLength OOM failure since being out of sync is safe
// so long as we have *fewer* items than our internal list. // so long as we have *fewer* items than our internal list.
mItems.Clear(); mItems.Clear();

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

@ -90,7 +90,7 @@ protected:
* increased, in which case the list will be left unmodified. * increased, in which case the list will be left unmodified.
*/ */
bool SetLength(uint32_t aNumberOfItems) { bool SetLength(uint32_t aNumberOfItems) {
return mLengths.SetLength(aNumberOfItems); return mLengths.SetLength(aNumberOfItems, fallible);
} }
private: private:

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

@ -91,7 +91,7 @@ protected:
* increased, in which case the list will be left unmodified. * increased, in which case the list will be left unmodified.
*/ */
bool SetLength(uint32_t aNumberOfItems) { bool SetLength(uint32_t aNumberOfItems) {
return mNumbers.SetLength(aNumberOfItems); return mNumbers.SetLength(aNumberOfItems, fallible);
} }
private: private:

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

@ -81,7 +81,7 @@ SVGPathData::AppendSeg(uint32_t aType, ...)
{ {
uint32_t oldLength = mData.Length(); uint32_t oldLength = mData.Length();
uint32_t newLength = oldLength + 1 + SVGPathSegUtils::ArgCountForType(aType); uint32_t newLength = oldLength + 1 + SVGPathSegUtils::ArgCountForType(aType);
if (!mData.SetLength(newLength)) { if (!mData.SetLength(newLength, fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }

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

@ -202,7 +202,7 @@ protected:
* increased, in which case the list will be left unmodified. * increased, in which case the list will be left unmodified.
*/ */
bool SetLength(uint32_t aLength) { bool SetLength(uint32_t aLength) {
return mData.SetLength(aLength); return mData.SetLength(aLength, fallible);
} }
nsresult SetValueFromString(const nsAString& aValue); nsresult SetValueFromString(const nsAString& aValue);

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

@ -99,7 +99,7 @@ protected:
* increased, in which case the list will be left unmodified. * increased, in which case the list will be left unmodified.
*/ */
bool SetLength(uint32_t aNumberOfItems) { bool SetLength(uint32_t aNumberOfItems) {
return mItems.SetLength(aNumberOfItems); return mItems.SetLength(aNumberOfItems, fallible);
} }
private: private:

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

@ -92,7 +92,7 @@ protected:
* increased, in which case the list will be left unmodified. * increased, in which case the list will be left unmodified.
*/ */
bool SetLength(uint32_t aStringOfItems) { bool SetLength(uint32_t aStringOfItems) {
return mStrings.SetLength(aStringOfItems); return mStrings.SetLength(aStringOfItems, fallible);
} }
private: private:

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

@ -94,7 +94,7 @@ protected:
* increased, in which case the list will be left unmodified. * increased, in which case the list will be left unmodified.
*/ */
bool SetLength(uint32_t aNumberOfItems) { bool SetLength(uint32_t aNumberOfItems) {
return mItems.SetLength(aNumberOfItems); return mItems.SetLength(aNumberOfItems, fallible);
} }
private: private:

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

@ -461,7 +461,7 @@ gfxContext::CurrentDash(FallibleTArray<gfxFloat>& dashes, gfxFloat* offset) cons
const AzureState &state = CurrentState(); const AzureState &state = CurrentState();
int count = state.strokeOptions.mDashLength; int count = state.strokeOptions.mDashLength;
if (count <= 0 || !dashes.SetLength(count)) { if (count <= 0 || !dashes.SetLength(count, fallible)) {
return false; return false;
} }

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

@ -315,7 +315,7 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText,
static const int32_t NO_GLYPH = -1; static const int32_t NO_GLYPH = -1;
AutoFallibleTArray<int32_t,SMALL_GLYPH_RUN> charToGlyphArray; AutoFallibleTArray<int32_t,SMALL_GLYPH_RUN> charToGlyphArray;
if (!charToGlyphArray.SetLength(stringRange.length)) { if (!charToGlyphArray.SetLength(stringRange.length, fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
int32_t *charToGlyph = charToGlyphArray.Elements(); int32_t *charToGlyph = charToGlyphArray.Elements();

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

@ -213,10 +213,10 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxContext *aContext,
AutoFallibleTArray<float,SMALL_GLYPH_RUN> xLocs; AutoFallibleTArray<float,SMALL_GLYPH_RUN> xLocs;
AutoFallibleTArray<float,SMALL_GLYPH_RUN> yLocs; AutoFallibleTArray<float,SMALL_GLYPH_RUN> yLocs;
if (!clusters.SetLength(aLength) || if (!clusters.SetLength(aLength, fallible) ||
!gids.SetLength(glyphCount) || !gids.SetLength(glyphCount, fallible) ||
!xLocs.SetLength(glyphCount) || !xLocs.SetLength(glyphCount, fallible) ||
!yLocs.SetLength(glyphCount)) !yLocs.SetLength(glyphCount, fallible))
{ {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }

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

@ -1534,7 +1534,7 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxContext *aContext,
uint32_t wordLength = aLength; uint32_t wordLength = aLength;
static const int32_t NO_GLYPH = -1; static const int32_t NO_GLYPH = -1;
AutoFallibleTArray<int32_t,SMALL_GLYPH_RUN> charToGlyphArray; AutoFallibleTArray<int32_t,SMALL_GLYPH_RUN> charToGlyphArray;
if (!charToGlyphArray.SetLength(wordLength)) { if (!charToGlyphArray.SetLength(wordLength, fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }

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

@ -370,7 +370,7 @@ CopyWOFFMetadata(const uint8_t* aFontData,
if (metaOffset >= aLength || metaCompLen > aLength - metaOffset) { if (metaOffset >= aLength || metaCompLen > aLength - metaOffset) {
return; return;
} }
if (!aMetadata->SetLength(woff->metaCompLen)) { if (!aMetadata->SetLength(woff->metaCompLen, fallible)) {
return; return;
} }
memcpy(aMetadata->Elements(), aFontData + metaOffset, metaCompLen); memcpy(aMetadata->Elements(), aFontData + metaOffset, metaCompLen);

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

@ -46,7 +46,7 @@ nsresult
nsHyphenator::Hyphenate(const nsAString& aString, nsHyphenator::Hyphenate(const nsAString& aString,
FallibleTArray<bool>& aHyphens) FallibleTArray<bool>& aHyphens)
{ {
if (!aHyphens.SetLength(aString.Length())) { if (!aHyphens.SetLength(aString.Length(), mozilla::fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
memset(aHyphens.Elements(), false, aHyphens.Length() * sizeof(bool)); memset(aHyphens.Elements(), false, aHyphens.Length() * sizeof(bool));

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

@ -343,7 +343,7 @@ def _callCxxArrayLength(arr):
def _callCxxCheckedArraySetLength(arr, lenexpr, sel='.'): def _callCxxCheckedArraySetLength(arr, lenexpr, sel='.'):
ifbad = StmtIf(ExprNot(ExprCall(ExprSelect(arr, sel, 'SetLength'), ifbad = StmtIf(ExprNot(ExprCall(ExprSelect(arr, sel, 'SetLength'),
args=[ lenexpr ]))) args=[ lenexpr, ExprVar('mozilla::fallible') ])))
ifbad.addifstmt(_fatalError('Error setting the array length')) ifbad.addifstmt(_fatalError('Error setting the array length'))
ifbad.addifstmt(StmtReturn.FALSE) ifbad.addifstmt(StmtReturn.FALSE)
return ifbad return ifbad

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

@ -1454,7 +1454,7 @@ GetStrokeDashData(nsIFrame* aFrame,
} else { } else {
uint32_t count = style->mStrokeDasharrayLength; uint32_t count = style->mStrokeDasharrayLength;
if (!count || !aDashes.SetLength(count)) { if (!count || !aDashes.SetLength(count, fallible)) {
return false; return false;
} }

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

@ -2205,7 +2205,7 @@ status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) {
} }
FallibleTArray<uint8_t> bufferBackend; FallibleTArray<uint8_t> bufferBackend;
if (!bufferBackend.SetLength(size + 1)) { if (!bufferBackend.SetLength(size + 1, mozilla::fallible)) {
// OOM ignore metadata. // OOM ignore metadata.
return OK; return OK;
} }
@ -3352,7 +3352,7 @@ bool MPEG4Source::ensureSrcBufferAllocated(int32_t aSize) {
if (mSrcBackend.Length() >= aSize) { if (mSrcBackend.Length() >= aSize) {
return true; return true;
} }
if (!mSrcBackend.SetLength(aSize)) { if (!mSrcBackend.SetLength(aSize, mozilla::fallible)) {
ALOGE("Error insufficient memory, requested %u bytes (had:%u)", ALOGE("Error insufficient memory, requested %u bytes (had:%u)",
aSize, mSrcBackend.Length()); aSize, mSrcBackend.Length());
return false; return false;

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

@ -204,7 +204,7 @@ bool MediaBuffer::ensuresize(size_t length) {
if (!mOwnsData || refcount()) { if (!mOwnsData || refcount()) {
return false; return false;
} }
if (!mBufferBackend.SetLength(length)) { if (!mBufferBackend.SetLength(length, mozilla::fallible)) {
return false; return false;
} }
mData = mBufferBackend.Elements(); mData = mBufferBackend.Elements();

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

@ -81,7 +81,7 @@ ChunkSet::Remove(const ChunkSet& aOther)
} }
} }
if (!mChunks.SetLength(addIter - mChunks.Elements())) { if (!mChunks.SetLength(addIter - mChunks.Elements(), fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }

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

@ -289,7 +289,7 @@ template<class T>
nsresult nsresult
ReadTArray(nsIInputStream* aStream, FallibleTArray<T>* aArray, uint32_t aNumElements) ReadTArray(nsIInputStream* aStream, FallibleTArray<T>* aArray, uint32_t aNumElements)
{ {
if (!aArray->SetLength(aNumElements)) if (!aArray->SetLength(aNumElements, fallible))
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
void *buffer = aArray->Elements(); void *buffer = aArray->Elements();

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

@ -579,7 +579,7 @@ nsresult DeflateWriteTArray(nsIOutputStream* aStream, nsTArray<T>& aIn)
uLongf insize = aIn.Length() * sizeof(T); uLongf insize = aIn.Length() * sizeof(T);
uLongf outsize = compressBound(insize); uLongf outsize = compressBound(insize);
FallibleTArray<char> outBuff; FallibleTArray<char> outBuff;
if (!outBuff.SetLength(outsize)) { if (!outBuff.SetLength(outsize, fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
@ -622,7 +622,7 @@ nsresult InflateReadTArray(nsIInputStream* aStream, FallibleTArray<T>* aOut,
NS_ASSERTION(read == sizeof(inLen), "Error reading inflate length"); NS_ASSERTION(read == sizeof(inLen), "Error reading inflate length");
FallibleTArray<char> inBuff; FallibleTArray<char> inBuff;
if (!inBuff.SetLength(inLen)) { if (!inBuff.SetLength(inLen, fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }
@ -631,7 +631,7 @@ nsresult InflateReadTArray(nsIInputStream* aStream, FallibleTArray<T>* aOut,
uLongf insize = inLen; uLongf insize = inLen;
uLongf outsize = aExpectedSize * sizeof(T); uLongf outsize = aExpectedSize * sizeof(T);
if (!aOut->SetLength(aExpectedSize)) { if (!aOut->SetLength(aExpectedSize, fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }

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

@ -133,7 +133,7 @@ nsUrlClassifierPrefixSet::MakePrefixSet(const uint32_t* aPrefixes, uint32_t aLen
nsresult nsresult
nsUrlClassifierPrefixSet::GetPrefixesNative(FallibleTArray<uint32_t>& outArray) nsUrlClassifierPrefixSet::GetPrefixesNative(FallibleTArray<uint32_t>& outArray)
{ {
if (!outArray.SetLength(mTotalPrefixes)) { if (!outArray.SetLength(mTotalPrefixes, fallible)) {
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
} }