Bug 968520 - Add mozilla::fallible to Fallible{Auto,}TArray::SetCapacity calls. r=froydnj
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Mon, 18 May 2015 13:50:34 -0700
changeset 244447 b589dae2c2930a5fefb9ed5cb4df7232e3e8251b
parent 244446 7464e2ba391c7e41c09d05c5778730b4d67abbee
child 244448 808811474fe74102d9b90ca29083f13f1a1a1d83
push id28781
push usercbook@mozilla.com
push dateTue, 19 May 2015 10:01:15 +0000
treeherdermozilla-central@4fb7ff694bf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs968520
milestone41.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 968520 - Add mozilla::fallible to Fallible{Auto,}TArray::SetCapacity calls. r=froydnj
dom/base/nsDOMMutationObserver.cpp
dom/base/nsJSTimeoutHandler.cpp
dom/bindings/Codegen.py
dom/camera/DOMCameraControl.cpp
dom/indexedDB/ActorsParent.cpp
dom/indexedDB/IDBObjectStore.cpp
dom/media/MediaData.cpp
dom/mobilemessage/ipc/SmsChild.cpp
dom/smil/nsSMILAnimationFunction.cpp
dom/svg/DOMSVGLengthList.cpp
dom/svg/DOMSVGNumberList.cpp
dom/svg/DOMSVGPathSegList.cpp
dom/svg/DOMSVGPointList.cpp
dom/svg/DOMSVGTransformList.cpp
dom/svg/SVGLengthList.cpp
dom/svg/SVGLengthList.h
dom/svg/SVGMotionSMILType.cpp
dom/svg/SVGNumberList.cpp
dom/svg/SVGNumberList.h
dom/svg/SVGPathData.cpp
dom/svg/SVGPathData.h
dom/svg/SVGPointList.h
dom/svg/SVGStringList.cpp
dom/svg/SVGStringList.h
dom/svg/SVGTransformList.cpp
dom/svg/SVGTransformList.h
dom/svg/SVGTransformListSMILType.cpp
intl/uconv/nsConverterInputStream.cpp
ipc/glue/IPCMessageUtils.h
netwerk/base/Dashboard.cpp
toolkit/components/url-classifier/HashStore.cpp
xpcom/io/nsUnicharInputStream.cpp
--- a/dom/base/nsDOMMutationObserver.cpp
+++ b/dom/base/nsDOMMutationObserver.cpp
@@ -755,17 +755,17 @@ nsDOMMutationObserver::HandleMutation()
   if (!mPendingMutationCount || !outer ||
       outer->GetCurrentInnerWindow() != mOwner) {
     ClearPendingRecords();
     return;
   }
 
   mozilla::dom::Sequence<mozilla::dom::OwningNonNull<nsDOMMutationRecord> >
     mutations;
-  if (mutations.SetCapacity(mPendingMutationCount)) {
+  if (mutations.SetCapacity(mPendingMutationCount, mozilla::fallible)) {
     // We can't use TakeRecords easily here, because it deals with a
     // different type of array, and we want to optimize out any extra copying.
     nsRefPtr<nsDOMMutationRecord> current;
     current.swap(mFirstPendingMutation);
     for (uint32_t i = 0; i < mPendingMutationCount; ++i) {
       nsRefPtr<nsDOMMutationRecord> next;
       current->mNext.swap(next);
       *mutations.AppendElement() = current;
--- a/dom/base/nsJSTimeoutHandler.cpp
+++ b/dom/base/nsJSTimeoutHandler.cpp
@@ -358,17 +358,17 @@ nsJSScriptTimeoutHandler::Init(nsGlobalW
     // Create our arg array.  argc is the number of arguments passed
     // to setTimeout or setInterval; the first two are our callback
     // and the delay, so only arguments after that need to go in our
     // array.
     // std::max(argc - 2, 0) wouldn't work right because argc is unsigned.
     uint32_t argCount = std::max(argc, 2u) - 2;
 
     FallibleTArray<JS::Heap<JS::Value> > args;
-    if (!args.SetCapacity(argCount)) {
+    if (!args.SetCapacity(argCount, fallible)) {
       // No need to drop here, since we already have a non-null mFunction
       return NS_ERROR_OUT_OF_MEMORY;
     }
     for (uint32_t idx = 0; idx < argCount; ++idx) {
       *args.AppendElement() = argv[idx + 2];
     }
     args.SwapElements(mArgs);
   } else {
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -5597,17 +5597,17 @@ class CGArgumentConverter(CGThing):
         replacer["elemType"] = typeConversion.declType.define()
 
         # NOTE: Keep this in sync with sequence conversions as needed
         variadicConversion = string.Template(
             "${seqType} ${declName};\n" +
             rooterDecl +
             dedent("""
                 if (${argc} > ${index}) {
-                  if (!${declName}.SetCapacity(${argc} - ${index})) {
+                  if (!${declName}.SetCapacity(${argc} - ${index}, mozilla::fallible)) {
                     JS_ReportOutOfMemory(cx);
                     return false;
                   }
                   for (uint32_t variadicArg = ${index}; variadicArg < ${argc}; ++variadicArg) {
                     ${elemType}& slot = *${declName}.AppendElement();
                 """)
         ).substitute(replacer)
 
--- a/dom/camera/DOMCameraControl.cpp
+++ b/dom/camera/DOMCameraControl.cpp
@@ -1369,17 +1369,17 @@ void
 nsDOMCameraControl::OnFacesDetected(const nsTArray<ICameraControl::Face>& aFaces)
 {
   DOM_CAMERA_LOGI("DOM OnFacesDetected %zu face(s)\n", aFaces.Length());
   MOZ_ASSERT(NS_IsMainThread());
 
   Sequence<OwningNonNull<DOMCameraDetectedFace> > faces;
   uint32_t len = aFaces.Length();
 
-  if (faces.SetCapacity(len)) {
+  if (faces.SetCapacity(len, fallible)) {
     for (uint32_t i = 0; i < len; ++i) {
       *faces.AppendElement() =
         new DOMCameraDetectedFace(static_cast<DOMMediaStream*>(this), aFaces[i]);
     }
   }
 
   CameraFacesDetectedEventInit eventInit;
   eventInit.mFaces.SetValue(faces);
--- a/dom/indexedDB/ActorsParent.cpp
+++ b/dom/indexedDB/ActorsParent.cpp
@@ -2711,17 +2711,18 @@ InsertIndexDataValuesFunction::OnFunctio
 
   Key value;
   rv = value.SetFromValueArray(aValues, 3);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Update the array with the new addition.
-  if (NS_WARN_IF(!indexValues.SetCapacity(indexValues.Length() + 1))) {
+  if (NS_WARN_IF(!indexValues.SetCapacity(indexValues.Length() + 1,
+                                          fallible))) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   MOZ_ALWAYS_TRUE(
     indexValues.InsertElementSorted(IndexDataValue(indexId, !!unique, value)));
 
   // Compress the array.
@@ -8103,24 +8104,25 @@ ConvertBlobsToActors(PBackgroundParent* 
   MOZ_ASSERT(exists);
 
   DebugOnly<bool> isDirectory;
   MOZ_ASSERT(NS_SUCCEEDED(directory->IsDirectory(&isDirectory)));
   MOZ_ASSERT(isDirectory);
 
   const uint32_t count = aFiles.Length();
 
-  if (NS_WARN_IF(!aActors.SetCapacity(count))) {
+  if (NS_WARN_IF(!aActors.SetCapacity(count, fallible))) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   const bool collectFileInfos =
     !BackgroundParent::IsOtherProcessActor(aBackgroundActor);
 
-  if (collectFileInfos && NS_WARN_IF(!aFileInfos.SetCapacity(count))) {
+  if (collectFileInfos &&
+      NS_WARN_IF(!aFileInfos.SetCapacity(count, fallible))) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   for (uint32_t index = 0; index < count; index++) {
     const StructuredCloneFile& file = aFiles[index];
 
     const int64_t fileId = file.mFileInfo->Id();
     MOZ_ASSERT(fileId > 0);
@@ -11574,17 +11576,17 @@ Database::Invalidate()
       AssertIsOnBackgroundThread();
 
       const uint32_t count = aTable.Count();
       if (!count) {
         return true;
       }
 
       FallibleTArray<nsRefPtr<TransactionBase>> transactions;
-      if (NS_WARN_IF(!transactions.SetCapacity(count))) {
+      if (NS_WARN_IF(!transactions.SetCapacity(count, fallible))) {
         return false;
       }
 
       aTable.EnumerateEntries(Collect, &transactions);
 
       if (NS_WARN_IF(transactions.Length() != count)) {
         return false;
       }
@@ -11922,17 +11924,17 @@ Database::AllocPBackgroundIDBTransaction
   const uint32_t nameCount = aObjectStoreNames.Length();
 
   if (NS_WARN_IF(nameCount > objectStores.Count())) {
     ASSERT_UNLESS_FUZZING();
     return nullptr;
   }
 
   FallibleTArray<nsRefPtr<FullObjectStoreMetadata>> fallibleObjectStores;
-  if (NS_WARN_IF(!fallibleObjectStores.SetCapacity(nameCount))) {
+  if (NS_WARN_IF(!fallibleObjectStores.SetCapacity(nameCount, fallible))) {
     return nullptr;
   }
 
   for (uint32_t nameIndex = 0; nameIndex < nameCount; nameIndex++) {
     const nsString& name = aObjectStoreNames[nameIndex];
 
     if (nameIndex) {
       // Make sure that this name is sorted properly and not a duplicate.
@@ -15951,17 +15953,17 @@ DatabaseOperationBase::IndexDataValuesFr
                  js::ProfileEntry::Category::STORAGE);
 
   const uint32_t count = aUpdateInfos.Length();
 
   if (!count) {
     return NS_OK;
   }
 
-  if (NS_WARN_IF(!aIndexValues.SetCapacity(count))) {
+  if (NS_WARN_IF(!aIndexValues.SetCapacity(count, fallible))) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   for (uint32_t idxIndex = 0; idxIndex < count; idxIndex++) {
     const IndexUpdateInfo& updateInfo = aUpdateInfos[idxIndex];
     const int64_t& indexId = updateInfo.indexId();
     const Key& key = updateInfo.value();
@@ -20385,17 +20387,17 @@ UpdateIndexDataValuesFunction::OnFunctio
     return rv;
   }
 
   const bool hadPreviousIndexValues = !indexValues.IsEmpty();
 
   const uint32_t updateInfoCount = updateInfos.Length();
 
   if (NS_WARN_IF(!indexValues.SetCapacity(indexValues.Length() +
-                                          updateInfoCount))) {
+                                          updateInfoCount, fallible))) {
     IDB_REPORT_INTERNAL_ERR();
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   // First construct the full list to update the index_data_values row.
   for (uint32_t index = 0; index < updateInfoCount; index++) {
     const IndexUpdateInfo& info = updateInfos[index];
 
@@ -21140,17 +21142,17 @@ ObjectStoreAddOrPutRequestOp::Init(Trans
   }
 #endif
 
   const nsTArray<DatabaseFileOrMutableFileId>& files = mParams.files();
 
   if (!files.IsEmpty()) {
     const uint32_t count = files.Length();
 
-    if (NS_WARN_IF(!mStoredFileInfos.SetCapacity(count))) {
+    if (NS_WARN_IF(!mStoredFileInfos.SetCapacity(count, fallible))) {
       return false;
     }
 
     nsRefPtr<FileManager> fileManager =
       aTransaction->GetDatabase()->GetFileManager();
     MOZ_ASSERT(fileManager);
 
     for (uint32_t index = 0; index < count; index++) {
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -1201,17 +1201,17 @@ IDBObjectStore::AddOrPut(JSContext* aCx,
     cloneWriteInfo.mBlobOrFileInfos;
 
   FallibleTArray<nsRefPtr<FileInfo>> fileInfosToKeepAlive;
 
   if (!blobOrFileInfos.IsEmpty()) {
     const uint32_t count = blobOrFileInfos.Length();
 
     FallibleTArray<DatabaseFileOrMutableFileId> fileActorOrMutableFileIds;
-    if (NS_WARN_IF(!fileActorOrMutableFileIds.SetCapacity(count))) {
+    if (NS_WARN_IF(!fileActorOrMutableFileIds.SetCapacity(count, fallible))) {
       aRv = NS_ERROR_OUT_OF_MEMORY;
       return nullptr;
     }
 
     IDBDatabase* database = mTransaction->Database();
 
     for (uint32_t index = 0; index < count; index++) {
       StructuredCloneWriteInfo::BlobOrFileInfo& blobOrFileInfo =
--- a/dom/media/MediaData.cpp
+++ b/dom/media/MediaData.cpp
@@ -538,17 +538,17 @@ MediaRawData::Clone() const
 }
 
 bool
 MediaRawData::EnsureCapacity(size_t aSize)
 {
   if (mData && mBuffer->Capacity() >= aSize + RAW_DATA_ALIGNMENT * 2) {
     return true;
   }
-  if (!mBuffer->SetCapacity(aSize + RAW_DATA_ALIGNMENT * 2)) {
+  if (!mBuffer->SetCapacity(aSize + RAW_DATA_ALIGNMENT * 2, fallible)) {
     return false;
   }
   // Find alignment address.
   const uintptr_t alignmask = RAW_DATA_ALIGNMENT;
   mData = reinterpret_cast<uint8_t*>(
     (reinterpret_cast<uintptr_t>(mBuffer->Elements()) + alignmask) & ~alignmask);
   MOZ_ASSERT(uintptr_t(mData) % (RAW_DATA_ALIGNMENT+1) == 0);
 
--- a/dom/mobilemessage/ipc/SmsChild.cpp
+++ b/dom/mobilemessage/ipc/SmsChild.cpp
@@ -343,20 +343,20 @@ MobileMessageCursorChild::HandleContinue
 
 void
 MobileMessageCursorChild::DoNotifyResult(const nsTArray<MobileMessageData>& aDataArray)
 {
   const uint32_t length = aDataArray.Length();
   MOZ_ASSERT(length);
 
   AutoFallibleTArray<nsISupports*, 1> autoArray;
-  NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length));
+  NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length, fallible));
 
   AutoFallibleTArray<nsCOMPtr<nsISupports>, 1> messages;
-  NS_ENSURE_TRUE_VOID(messages.SetCapacity(length));
+  NS_ENSURE_TRUE_VOID(messages.SetCapacity(length, fallible));
 
   for (uint32_t i = 0; i < length; i++) {
     nsCOMPtr<nsISupports> message = CreateMessageFromMessageData(aDataArray[i]);
     NS_ENSURE_TRUE_VOID(messages.AppendElement(message));
     NS_ENSURE_TRUE_VOID(autoArray.AppendElement(message.get()));
   }
 
   mCursorCallback->NotifyCursorResult(autoArray.Elements(), length);
@@ -364,20 +364,20 @@ MobileMessageCursorChild::DoNotifyResult
 
 void
 MobileMessageCursorChild::DoNotifyResult(const nsTArray<ThreadData>& aDataArray)
 {
   const uint32_t length = aDataArray.Length();
   MOZ_ASSERT(length);
 
   AutoFallibleTArray<nsISupports*, 1> autoArray;
-  NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length));
+  NS_ENSURE_TRUE_VOID(autoArray.SetCapacity(length, fallible));
 
   AutoFallibleTArray<nsCOMPtr<nsISupports>, 1> threads;
-  NS_ENSURE_TRUE_VOID(threads.SetCapacity(length));
+  NS_ENSURE_TRUE_VOID(threads.SetCapacity(length, fallible));
 
   for (uint32_t i = 0; i < length; i++) {
     nsCOMPtr<nsISupports> thread = new MobileMessageThread(aDataArray[i]);
     NS_ENSURE_TRUE_VOID(threads.AppendElement(thread));
     NS_ENSURE_TRUE_VOID(autoArray.AppendElement(thread.get()));
   }
 
   mCursorCallback->NotifyCursorResult(autoArray.Elements(), length);
--- a/dom/smil/nsSMILAnimationFunction.cpp
+++ b/dom/smil/nsSMILAnimationFunction.cpp
@@ -775,17 +775,17 @@ nsSMILAnimationFunction::GetValues(const
                          preventCachingOfSandwich);
     parseOk &= ParseAttr(nsGkAtoms::by,   aSMILAttr, by,
                          preventCachingOfSandwich);
 
     if (preventCachingOfSandwich) {
       mValueNeedsReparsingEverySample = true;
     }
 
-    if (!parseOk || !result.SetCapacity(2)) {
+    if (!parseOk || !result.SetCapacity(2, mozilla::fallible)) {
       return NS_ERROR_FAILURE;
     }
 
     if (!to.IsNull()) {
       if (!from.IsNull()) {
         result.AppendElement(from);
         result.AppendElement(to);
       } else {
--- a/dom/svg/DOMSVGLengthList.cpp
+++ b/dom/svg/DOMSVGLengthList.cpp
@@ -250,17 +250,17 @@ DOMSVGLengthList::InsertItemBefore(DOMSV
     error.Throw(NS_ERROR_DOM_SVG_WRONG_TYPE_ERR);
     return nullptr;
   }
   if (domItem->HasOwner() || domItem->IsReflectingAttribute()) {
     domItem = domItem->Copy(); // must do this before changing anything!
   }
 
   // Ensure we have enough memory so we can avoid complex error handling below:
-  if (!mItems.SetCapacity(mItems.Length() + 1) ||
+  if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
       !InternalList().SetCapacity(InternalList().Length() + 1)) {
     error.Throw(NS_ERROR_OUT_OF_MEMORY);
     return nullptr;
   }
 
   AutoChangeLengthListNotifier notifier(this);
   // Now that we know we're inserting, keep animVal list in sync as necessary.
   MaybeInsertNullInAnimValListAt(index);
--- a/dom/svg/DOMSVGNumberList.cpp
+++ b/dom/svg/DOMSVGNumberList.cpp
@@ -234,17 +234,17 @@ DOMSVGNumberList::InsertItemBefore(DOMSV
     error.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return nullptr;
   }
 
   // must do this before changing anything!
   nsRefPtr<DOMSVGNumber> domItem = aItem.HasOwner() ? aItem.Clone() : &aItem;
 
   // Ensure we have enough memory so we can avoid complex error handling below:
-  if (!mItems.SetCapacity(mItems.Length() + 1) ||
+  if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
       !InternalList().SetCapacity(InternalList().Length() + 1)) {
     error.Throw(NS_ERROR_OUT_OF_MEMORY);
     return nullptr;
   }
 
   AutoChangeNumberListNotifier notifier(this);
   // Now that we know we're inserting, keep animVal list in sync as necessary.
   MaybeInsertNullInAnimValListAt(index);
--- a/dom/svg/DOMSVGPathSegList.cpp
+++ b/dom/svg/DOMSVGPathSegList.cpp
@@ -365,18 +365,19 @@ DOMSVGPathSegList::InsertItemBefore(DOMS
   nsRefPtr<DOMSVGPathSeg> domItem = &aNewItem;
   if (domItem->HasOwner()) {
     domItem = domItem->Clone(); // must do this before changing anything!
   }
 
   uint32_t argCount = SVGPathSegUtils::ArgCountForType(domItem->Type());
 
   // Ensure we have enough memory so we can avoid complex error handling below:
-  if (!mItems.SetCapacity(mItems.Length() + 1) ||
-      !InternalList().mData.SetCapacity(InternalList().mData.Length() + 1 + argCount)) {
+  if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
+      !InternalList().mData.SetCapacity(InternalList().mData.Length() + 1 + argCount,
+                                        fallible)) {
     aError.Throw(NS_ERROR_OUT_OF_MEMORY);
     return nullptr;
   }
 
   AutoChangePathSegListNotifier notifier(this);
   // Now that we know we're inserting, keep animVal list in sync as necessary.
   MaybeInsertNullInAnimValListAt(aIndex, internalIndex, argCount);
 
--- a/dom/svg/DOMSVGPointList.cpp
+++ b/dom/svg/DOMSVGPointList.cpp
@@ -301,17 +301,17 @@ DOMSVGPointList::InsertItemBefore(nsISVG
 
   nsCOMPtr<nsISVGPoint> domItem = &aNewItem;
   if (domItem->HasOwner() || domItem->IsReadonly() ||
       domItem->IsTranslatePoint()) {
     domItem = domItem->Copy(); // must do this before changing anything!
   }
 
   // Ensure we have enough memory so we can avoid complex error handling below:
-  if (!mItems.SetCapacity(mItems.Length() + 1) ||
+  if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
       !InternalList().SetCapacity(InternalList().Length() + 1)) {
     aError.Throw(NS_ERROR_OUT_OF_MEMORY);
     return nullptr;
   }
 
   AutoChangePointListNotifier notifier(this);
   // Now that we know we're inserting, keep animVal list in sync as necessary.
   MaybeInsertNullInAnimValListAt(aIndex);
--- a/dom/svg/DOMSVGTransformList.cpp
+++ b/dom/svg/DOMSVGTransformList.cpp
@@ -242,17 +242,17 @@ DOMSVGTransformList::InsertItemBefore(SV
   }
 
   nsRefPtr<SVGTransform> domItem = &newItem;
   if (newItem.HasOwner()) {
     domItem = newItem.Clone(); // must do this before changing anything!
   }
 
   // Ensure we have enough memory so we can avoid complex error handling below:
-  if (!mItems.SetCapacity(mItems.Length() + 1) ||
+  if (!mItems.SetCapacity(mItems.Length() + 1, fallible) ||
       !InternalList().SetCapacity(InternalList().Length() + 1)) {
     error.Throw(NS_ERROR_OUT_OF_MEMORY);
     return nullptr;
   }
 
   AutoChangeTransformListNotifier notifier(this);
   // Now that we know we're inserting, keep animVal list in sync as necessary.
   MaybeInsertNullInAnimValListAt(index);
--- a/dom/svg/SVGLengthList.cpp
+++ b/dom/svg/SVGLengthList.cpp
@@ -13,17 +13,17 @@
 #include "SVGContentUtils.h"
 #include "SVGLength.h"
 
 namespace mozilla {
 
 nsresult
 SVGLengthList::CopyFrom(const SVGLengthList& rhs)
 {
-  if (!mLengths.SetCapacity(rhs.Length())) {
+  if (!mLengths.SetCapacity(rhs.Length(), fallible)) {
     // Yes, we do want fallible alloc here
     return NS_ERROR_OUT_OF_MEMORY;
   }
   mLengths = rhs.mLengths;
   return NS_OK;
 }
 
 void
--- a/dom/svg/SVGLengthList.h
+++ b/dom/svg/SVGLengthList.h
@@ -54,17 +54,17 @@ public:
 
   const SVGLength& operator[](uint32_t aIndex) const {
     return mLengths[aIndex];
   }
 
   bool operator==(const SVGLengthList& rhs) const;
 
   bool SetCapacity(uint32_t size) {
-    return mLengths.SetCapacity(size);
+    return mLengths.SetCapacity(size, fallible);
   }
 
   void Compact() {
     mLengths.Compact();
   }
 
   // Access to methods that can modify objects of this type is deliberately
   // limited. This is to reduce the chances of someone modifying objects of
--- a/dom/svg/SVGMotionSMILType.cpp
+++ b/dom/svg/SVGMotionSMILType.cpp
@@ -194,17 +194,17 @@ SVGMotionSMILType::Assign(nsSMILValue& a
 {
   MOZ_ASSERT(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   MOZ_ASSERT(aDest.mType == this, "Unexpected SMIL type");
 
   const MotionSegmentArray& srcArr = ExtractMotionSegmentArray(aSrc);
   MotionSegmentArray& dstArr = ExtractMotionSegmentArray(aDest);
 
   // Ensure we have sufficient memory.
-  if (!dstArr.SetCapacity(srcArr.Length())) {
+  if (!dstArr.SetCapacity(srcArr.Length(), fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   dstArr = srcArr; // Do the assignment.
   return NS_OK;
 }
 
 bool
--- a/dom/svg/SVGNumberList.cpp
+++ b/dom/svg/SVGNumberList.cpp
@@ -12,17 +12,17 @@
 #include "nsTextFormatter.h"
 #include "SVGContentUtils.h"
 
 namespace mozilla {
 
 nsresult
 SVGNumberList::CopyFrom(const SVGNumberList& rhs)
 {
-  if (!mNumbers.SetCapacity(rhs.Length())) {
+  if (!mNumbers.SetCapacity(rhs.Length(), fallible)) {
     // Yes, we do want fallible alloc here
     return NS_ERROR_OUT_OF_MEMORY;
   }
   mNumbers = rhs.mNumbers;
   return NS_OK;
 }
 
 void
--- a/dom/svg/SVGNumberList.h
+++ b/dom/svg/SVGNumberList.h
@@ -55,17 +55,17 @@ public:
     return mNumbers[aIndex];
   }
 
   bool operator==(const SVGNumberList& rhs) const {
     return mNumbers == rhs.mNumbers;
   }
 
   bool SetCapacity(uint32_t size) {
-    return mNumbers.SetCapacity(size);
+    return mNumbers.SetCapacity(size, fallible);
   }
 
   void Compact() {
     mNumbers.Compact();
   }
 
   // Access to methods that can modify objects of this type is deliberately
   // limited. This is to reduce the chances of someone modifying objects of
--- a/dom/svg/SVGPathData.cpp
+++ b/dom/svg/SVGPathData.cpp
@@ -29,17 +29,17 @@ static bool IsMoveto(uint16_t aSegType)
 {
   return aSegType == PATHSEG_MOVETO_ABS ||
          aSegType == PATHSEG_MOVETO_REL;
 }
 
 nsresult
 SVGPathData::CopyFrom(const SVGPathData& rhs)
 {
-  if (!mData.SetCapacity(rhs.mData.Length())) {
+  if (!mData.SetCapacity(rhs.mData.Length(), fallible)) {
     // Yes, we do want fallible alloc here
     return NS_ERROR_OUT_OF_MEMORY;
   }
   mData = rhs.mData;
   return NS_OK;
 }
 
 void
--- a/dom/svg/SVGPathData.h
+++ b/dom/svg/SVGPathData.h
@@ -130,17 +130,17 @@ public:
     // We use memcmp so that we don't need to worry that the data encoded in
     // the first float may have the same bit pattern as a NaN.
     return mData.Length() == rhs.mData.Length() &&
            memcmp(mData.Elements(), rhs.mData.Elements(),
                   mData.Length() * sizeof(float)) == 0;
   }
 
   bool SetCapacity(uint32_t aSize) {
-    return mData.SetCapacity(aSize);
+    return mData.SetCapacity(aSize, fallible);
   }
 
   void Compact() {
     mData.Compact();
   }
 
 
   float GetPathLength() const;
--- a/dom/svg/SVGPointList.h
+++ b/dom/svg/SVGPointList.h
@@ -63,17 +63,17 @@ public:
   bool operator==(const SVGPointList& rhs) const {
     // memcmp can be faster than |mItems == rhs.mItems|
     return mItems.Length() == rhs.mItems.Length() &&
            memcmp(mItems.Elements(), rhs.mItems.Elements(),
                   mItems.Length() * sizeof(SVGPoint)) == 0;
   }
 
   bool SetCapacity(uint32_t aSize) {
-    return mItems.SetCapacity(aSize);
+    return mItems.SetCapacity(aSize, fallible);
   }
 
   void Compact() {
     mItems.Compact();
   }
 
   // Access to methods that can modify objects of this type is deliberately
   // limited. This is to reduce the chances of someone modifying objects of
--- a/dom/svg/SVGStringList.cpp
+++ b/dom/svg/SVGStringList.cpp
@@ -11,17 +11,17 @@
 #include "nsWhitespaceTokenizer.h"
 #include "SVGContentUtils.h"
 
 namespace mozilla {
 
 nsresult
 SVGStringList::CopyFrom(const SVGStringList& rhs)
 {
-  if (!mStrings.SetCapacity(rhs.Length())) {
+  if (!mStrings.SetCapacity(rhs.Length(), fallible)) {
     // Yes, we do want fallible alloc here
     return NS_ERROR_OUT_OF_MEMORY;
   }
   mStrings = rhs.mStrings;
   mIsSet = true;
   return NS_OK;
 }
 
--- a/dom/svg/SVGStringList.h
+++ b/dom/svg/SVGStringList.h
@@ -51,17 +51,17 @@ public:
     return mStrings[aIndex];
   }
 
   bool operator==(const SVGStringList& rhs) const {
     return mStrings == rhs.mStrings;
   }
 
   bool SetCapacity(uint32_t size) {
-    return mStrings.SetCapacity(size);
+    return mStrings.SetCapacity(size, fallible);
   }
 
   void Compact() {
     mStrings.Compact();
   }
 
   // Returns true if the value of this stringlist has been explicitly
   // set by markup or a DOM call, false otherwise.
--- a/dom/svg/SVGTransformList.cpp
+++ b/dom/svg/SVGTransformList.cpp
@@ -38,17 +38,17 @@ nsresult
 SVGTransformList::CopyFrom(const SVGTransformList& rhs)
 {
   return CopyFrom(rhs.mItems);
 }
 
 nsresult
 SVGTransformList::CopyFrom(const nsTArray<nsSVGTransform>& aTransformArray)
 {
-  if (!mItems.SetCapacity(aTransformArray.Length())) {
+  if (!mItems.SetCapacity(aTransformArray.Length(), fallible)) {
     // Yes, we do want fallible alloc here
     return NS_ERROR_OUT_OF_MEMORY;
   }
   mItems = aTransformArray;
   return NS_OK;
 }
 
 void
--- a/dom/svg/SVGTransformList.h
+++ b/dom/svg/SVGTransformList.h
@@ -55,17 +55,17 @@ public:
     return mItems[aIndex];
   }
 
   bool operator==(const SVGTransformList& rhs) const {
     return mItems == rhs.mItems;
   }
 
   bool SetCapacity(uint32_t size) {
-    return mItems.SetCapacity(size);
+    return mItems.SetCapacity(size, fallible);
   }
 
   void Compact() {
     mItems.Compact();
   }
 
   gfxMatrix GetConsolidationMatrix() const;
 
--- a/dom/svg/SVGTransformListSMILType.cpp
+++ b/dom/svg/SVGTransformListSMILType.cpp
@@ -45,17 +45,17 @@ SVGTransformListSMILType::Assign(nsSMILV
   NS_PRECONDITION(aDest.mType == aSrc.mType, "Incompatible SMIL types");
   NS_PRECONDITION(aDest.mType == this, "Unexpected SMIL value");
 
   const TransformArray* srcTransforms =
     static_cast<const TransformArray*>(aSrc.mU.mPtr);
   TransformArray* dstTransforms = static_cast<TransformArray*>(aDest.mU.mPtr);
 
   // Before we assign, ensure we have sufficient memory
-  bool result = dstTransforms->SetCapacity(srcTransforms->Length());
+  bool result = dstTransforms->SetCapacity(srcTransforms->Length(), fallible);
   NS_ENSURE_TRUE(result,NS_ERROR_OUT_OF_MEMORY);
 
   *dstTransforms = *srcTransforms;
 
   return NS_OK;
 }
 
 bool
@@ -331,17 +331,17 @@ SVGTransformListSMILType::AppendTransfor
 bool
 SVGTransformListSMILType::AppendTransforms(const SVGTransformList& aList,
                                            nsSMILValue& aValue)
 {
   NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type");
 
   TransformArray& transforms = *static_cast<TransformArray*>(aValue.mU.mPtr);
 
-  if (!transforms.SetCapacity(transforms.Length() + aList.Length()))
+  if (!transforms.SetCapacity(transforms.Length() + aList.Length(), fallible))
     return false;
 
   for (uint32_t i = 0; i < aList.Length(); ++i) {
     // No need to check the return value below since we have already allocated
     // the necessary space
     transforms.AppendElement(SVGTransformSMILData(aList[i]));
   }
   return true;
@@ -353,17 +353,17 @@ SVGTransformListSMILType::GetTransforms(
                                         FallibleTArray<nsSVGTransform>& aTransforms)
 {
   NS_PRECONDITION(aValue.mType == Singleton(), "Unexpected SMIL value type");
 
   const TransformArray& smilTransforms =
     *static_cast<const TransformArray*>(aValue.mU.mPtr);
 
   aTransforms.Clear();
-  if (!aTransforms.SetCapacity(smilTransforms.Length()))
+  if (!aTransforms.SetCapacity(smilTransforms.Length(), fallible))
       return false;
 
   for (uint32_t i = 0; i < smilTransforms.Length(); ++i) {
     // No need to check the return value below since we have already allocated
     // the necessary space
     aTransforms.AppendElement(smilTransforms[i].ToSVGTransform());
   }
   return true;
--- a/intl/uconv/nsConverterInputStream.cpp
+++ b/intl/uconv/nsConverterInputStream.cpp
@@ -40,18 +40,18 @@ nsConverterInputStream::Init(nsIInputStr
         encoding.Assign(label);
     } else if (!EncodingUtils::FindEncodingForLabelNoReplacement(label,
                                                                  encoding)) {
       return NS_ERROR_UCONV_NOCONV;
     }
     mConverter = EncodingUtils::DecoderForEncoding(encoding);
  
     // set up our buffers
-    if (!mByteData.SetCapacity(aBufferSize) ||
-        !mUnicharData.SetCapacity(aBufferSize)) {
+    if (!mByteData.SetCapacity(aBufferSize, mozilla::fallible) ||
+        !mUnicharData.SetCapacity(aBufferSize, mozilla::fallible)) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
     mInput = aStream;
     mReplacementChar = aReplacementChar;
     if (!aReplacementChar ||
         aReplacementChar != mConverter->GetCharacterForUnMapped()) {
         mConverter->SetInputErrorBehavior(nsIUnicodeDecoder::kOnError_Signal);
--- a/ipc/glue/IPCMessageUtils.h
+++ b/ipc/glue/IPCMessageUtils.h
@@ -515,17 +515,17 @@ struct ParamTraits<FallibleTArray<E> >
 
       E* elements = aResult->AppendElements(length);
       if (!elements) {
         return false;
       }
 
       memcpy(elements, outdata, pickledLength);
     } else {
-      if (!aResult->SetCapacity(length)) {
+      if (!aResult->SetCapacity(length, mozilla::fallible)) {
         return false;
       }
 
       for (uint32_t index = 0; index < length; index++) {
         E* element = aResult->AppendElement();
         MOZ_ASSERT(element);
         if (!ReadParam(aMsg, aIter, element)) {
           return false;
--- a/netwerk/base/Dashboard.cpp
+++ b/netwerk/base/Dashboard.cpp
@@ -382,17 +382,17 @@ Dashboard::GetSockets(SocketData *aSocke
     mozilla::dom::SocketsDict dict;
     dict.mSockets.Construct();
     dict.mSent = 0;
     dict.mReceived = 0;
 
     Sequence<mozilla::dom::SocketElement> &sockets = dict.mSockets.Value();
 
     uint32_t length = socketData->mData.Length();
-    if (!sockets.SetCapacity(length)) {
+    if (!sockets.SetCapacity(length, fallible)) {
             JS_ReportOutOfMemory(cx);
             return NS_ERROR_OUT_OF_MEMORY;
     }
 
     for (uint32_t i = 0; i < socketData->mData.Length(); i++) {
         mozilla::dom::SocketElement &mSocket = *sockets.AppendElement();
         CopyASCIItoUTF16(socketData->mData[i].host, mSocket.mHost);
         mSocket.mPort = socketData->mData[i].port;
@@ -452,17 +452,17 @@ Dashboard::GetHttpConnections(HttpData *
     dict.mConnections.Construct();
 
     using mozilla::dom::HalfOpenInfoDict;
     using mozilla::dom::HttpConnectionElement;
     using mozilla::dom::HttpConnInfo;
     Sequence<HttpConnectionElement> &connections = dict.mConnections.Value();
 
     uint32_t length = httpData->mData.Length();
-    if (!connections.SetCapacity(length)) {
+    if (!connections.SetCapacity(length, fallible)) {
             JS_ReportOutOfMemory(cx);
             return NS_ERROR_OUT_OF_MEMORY;
     }
 
     for (uint32_t i = 0; i < httpData->mData.Length(); i++) {
         HttpConnectionElement &connection = *connections.AppendElement();
 
         CopyASCIItoUTF16(httpData->mData[i].host, connection.mHost);
@@ -473,19 +473,20 @@ Dashboard::GetHttpConnections(HttpData *
         connection.mActive.Construct();
         connection.mIdle.Construct();
         connection.mHalfOpens.Construct();
 
         Sequence<HttpConnInfo> &active = connection.mActive.Value();
         Sequence<HttpConnInfo> &idle = connection.mIdle.Value();
         Sequence<HalfOpenInfoDict> &halfOpens = connection.mHalfOpens.Value();
 
-        if (!active.SetCapacity(httpData->mData[i].active.Length()) ||
-            !idle.SetCapacity(httpData->mData[i].idle.Length()) ||
-            !halfOpens.SetCapacity(httpData->mData[i].halfOpens.Length())) {
+        if (!active.SetCapacity(httpData->mData[i].active.Length(), fallible) ||
+            !idle.SetCapacity(httpData->mData[i].idle.Length(), fallible) ||
+            !halfOpens.SetCapacity(httpData->mData[i].halfOpens.Length(),
+                                   fallible)) {
                 JS_ReportOutOfMemory(cx);
                 return NS_ERROR_OUT_OF_MEMORY;
         }
 
         for (uint32_t j = 0; j < httpData->mData[i].active.Length(); j++) {
             HttpConnInfo &info = *active.AppendElement();
             info.mRtt = httpData->mData[i].active[j].rtt;
             info.mTtl = httpData->mData[i].active[j].ttl;
@@ -614,17 +615,17 @@ Dashboard::GetWebSocketConnections(WebSo
 
     mozilla::dom::WebSocketDict dict;
     dict.mWebsockets.Construct();
     Sequence<mozilla::dom::WebSocketElement> &websockets =
         dict.mWebsockets.Value();
 
     mozilla::MutexAutoLock lock(mWs.lock);
     uint32_t length = mWs.data.Length();
-    if (!websockets.SetCapacity(length)) {
+    if (!websockets.SetCapacity(length, fallible)) {
         JS_ReportOutOfMemory(cx);
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     for (uint32_t i = 0; i < mWs.data.Length(); i++) {
         mozilla::dom::WebSocketElement &websocket = *websockets.AppendElement();
         CopyASCIItoUTF16(mWs.data[i].mHost, websocket.mHostport);
         websocket.mMsgsent = mWs.data[i].mMsgSent;
@@ -687,27 +688,27 @@ Dashboard::GetDNSCacheEntries(DnsData *d
 {
     AutoSafeJSContext cx;
 
     mozilla::dom::DNSCacheDict dict;
     dict.mEntries.Construct();
     Sequence<mozilla::dom::DnsCacheEntry> &entries = dict.mEntries.Value();
 
     uint32_t length = dnsData->mData.Length();
-    if (!entries.SetCapacity(length)) {
+    if (!entries.SetCapacity(length, fallible)) {
         JS_ReportOutOfMemory(cx);
         return NS_ERROR_OUT_OF_MEMORY;
     }
 
     for (uint32_t i = 0; i < dnsData->mData.Length(); i++) {
         mozilla::dom::DnsCacheEntry &entry = *entries.AppendElement();
         entry.mHostaddr.Construct();
 
         Sequence<nsString> &addrs = entry.mHostaddr.Value();
-        if (!addrs.SetCapacity(dnsData->mData[i].hostaddr.Length())) {
+        if (!addrs.SetCapacity(dnsData->mData[i].hostaddr.Length(), fallible)) {
             JS_ReportOutOfMemory(cx);
             return NS_ERROR_OUT_OF_MEMORY;
         }
 
         CopyASCIItoUTF16(dnsData->mData[i].hostname, entry.mHostname);
         entry.mExpiration = dnsData->mData[i].expiration;
 
         for (uint32_t j = 0; j < dnsData->mData[i].hostaddr.Length(); j++) {
--- a/toolkit/components/url-classifier/HashStore.cpp
+++ b/toolkit/components/url-classifier/HashStore.cpp
@@ -699,17 +699,17 @@ ByteSliceRead(nsIInputStream* aInStream,
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = InflateReadTArray(aInStream, &slice3, count);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = ReadTArray(aInStream, &slice4, count);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (!aData->SetCapacity(count)) {
+  if (!aData->SetCapacity(count, fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   for (uint32_t i = 0; i < count; i++) {
     aData->AppendElement((slice1[i] << 24) | (slice2[i] << 16)
                          | (slice3[i] << 8) | (slice4[i]));
   }
 
@@ -720,17 +720,17 @@ nsresult
 HashStore::ReadAddPrefixes()
 {
   FallibleTArray<uint32_t> chunks;
   uint32_t count = mHeader.numAddPrefixes;
 
   nsresult rv = ByteSliceRead(mInputStream, &chunks, count);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (!mAddPrefixes.SetCapacity(count)) {
+  if (!mAddPrefixes.SetCapacity(count, fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   for (uint32_t i = 0; i < count; i++) {
     AddPrefix *add = mAddPrefixes.AppendElement();
     add->prefix.FromUint32(0);
     add->addChunk = chunks[i];
   }
 
@@ -749,17 +749,17 @@ HashStore::ReadSubPrefixes()
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = ByteSliceRead(mInputStream, &subchunks, count);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = ByteSliceRead(mInputStream, &prefixes, count);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  if (!mSubPrefixes.SetCapacity(count)) {
+  if (!mSubPrefixes.SetCapacity(count, fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   for (uint32_t i = 0; i < count; i++) {
     SubPrefix *sub = mSubPrefixes.AppendElement();
     sub->addChunk = addchunks[i];
     sub->prefix.FromUint32(prefixes[i]);
     sub->subChunk = subchunks[i];
   }
--- a/xpcom/io/nsUnicharInputStream.cpp
+++ b/xpcom/io/nsUnicharInputStream.cpp
@@ -157,18 +157,18 @@ UTF8InputStream::UTF8InputStream() :
   mUnicharDataOffset(0),
   mUnicharDataLength(0)
 {
 }
 
 nsresult
 UTF8InputStream::Init(nsIInputStream* aStream)
 {
-  if (!mByteData.SetCapacity(STRING_BUFFER_SIZE) ||
-      !mUnicharData.SetCapacity(STRING_BUFFER_SIZE)) {
+  if (!mByteData.SetCapacity(STRING_BUFFER_SIZE, mozilla::fallible) ||
+      !mUnicharData.SetCapacity(STRING_BUFFER_SIZE, mozilla::fallible)) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
   mInput = aStream;
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS(UTF8InputStream, nsIUnicharInputStream)