Bug 968520 - Always require fallible argument with FallibleTArray calls. r=froydnj

This commit is contained in:
Birunthan Mohanathas 2015-06-10 14:30:41 -07:00
Родитель 94f1cfa658
Коммит 3aad780da9
1 изменённых файлов: 49 добавлений и 1 удалений

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

@ -1222,6 +1222,7 @@ public:
// @param aArrayLen The number of values to copy into this array.
// @return A pointer to the new elements in the array, or null if
// the operation failed due to insufficient memory.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const Item* aArray, size_type aArrayLen)
@ -1238,7 +1239,7 @@ public:
AssignRange(aStart, aArrayLen, aArray);
return Elements() + aStart;
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -1251,6 +1252,7 @@ public:
}
// A variation on the ReplaceElementsAt method defined above.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const nsTArray<Item>& aArray)
@ -1258,6 +1260,7 @@ public:
return ReplaceElementsAt<Item, ActualAlloc>(
aStart, aCount, aArray.Elements(), aArray.Length());
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -1269,12 +1272,14 @@ public:
}
// A variation on the ReplaceElementsAt method defined above.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const Item& aItem)
{
return ReplaceElementsAt<Item, ActualAlloc>(aStart, aCount, &aItem, 1);
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -1292,12 +1297,14 @@ public:
}
// A variation on the ReplaceElementsAt method defined above.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* InsertElementsAt(index_type aIndex, const Item* aArray,
size_type aArrayLen)
{
return ReplaceElementsAt<Item, ActualAlloc>(aIndex, 0, aArray, aArrayLen);
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -1308,6 +1315,7 @@ public:
}
// A variation on the ReplaceElementsAt method defined above.
protected:
template<class Item, class Allocator, typename ActualAlloc = Alloc>
elem_type* InsertElementsAt(index_type aIndex,
const nsTArray_Impl<Item, Allocator>& aArray)
@ -1315,6 +1323,7 @@ public:
return ReplaceElementsAt<Item, ActualAlloc>(
aIndex, 0, aArray.Elements(), aArray.Length());
}
public:
template<class Item, class Allocator>
/* MOZ_WARN_UNUSED_RESULT */
@ -1328,6 +1337,7 @@ public:
// Insert a new element without copy-constructing. This is useful to avoid
// temporaries.
// @return A pointer to the newly inserted element, or null on OOM.
protected:
template<typename ActualAlloc = Alloc>
elem_type* InsertElementAt(index_type aIndex)
{
@ -1341,6 +1351,7 @@ public:
elem_traits::Construct(elem);
return elem;
}
public:
/* MOZ_WARN_UNUSED_RESULT */
elem_type* InsertElementAt(index_type aIndex, const mozilla::fallible_t&)
@ -1349,6 +1360,7 @@ public:
}
// Insert a new element, move constructing if possible.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* InsertElementAt(index_type aIndex, Item&& aItem)
{
@ -1362,6 +1374,7 @@ public:
elem_traits::Construct(elem, mozilla::Forward<Item>(aItem));
return elem;
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -1410,6 +1423,7 @@ public:
// Inserts |aItem| at such an index to guarantee that if the array
// was previously sorted, it will remain sorted after this
// insertion.
protected:
template<class Item, class Comparator, typename ActualAlloc = Alloc>
elem_type* InsertElementSorted(Item&& aItem, const Comparator& aComp)
{
@ -1417,6 +1431,7 @@ public:
return InsertElementAt<Item, ActualAlloc>(
index, mozilla::Forward<Item>(aItem));
}
public:
template<class Item, class Comparator>
/* MOZ_WARN_UNUSED_RESULT */
@ -1428,6 +1443,7 @@ public:
}
// A variation on the InsertElementSorted method defined above.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* InsertElementSorted(Item&& aItem)
{
@ -1435,6 +1451,7 @@ public:
return InsertElementSorted<Item, decltype(comp), ActualAlloc>(
mozilla::Forward<Item>(aItem), comp);
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -1449,6 +1466,7 @@ public:
// @param aArrayLen The number of elements to append to this array.
// @return A pointer to the new elements in the array, or null if
// the operation failed due to insufficient memory.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* AppendElements(const Item* aArray, size_type aArrayLen)
{
@ -1461,6 +1479,7 @@ public:
this->IncrementLength(aArrayLen);
return Elements() + len;
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -1471,11 +1490,13 @@ public:
}
// A variation on the AppendElements method defined above.
protected:
template<class Item, class Allocator, typename ActualAlloc = Alloc>
elem_type* AppendElements(const nsTArray_Impl<Item, Allocator>& aArray)
{
return AppendElements<Item, ActualAlloc>(aArray.Elements(), aArray.Length());
}
public:
template<class Item, class Allocator>
/* MOZ_WARN_UNUSED_RESULT */
@ -1486,6 +1507,7 @@ public:
}
// Append a new element, move constructing if possible.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* AppendElement(Item&& aItem)
{
@ -1498,6 +1520,7 @@ public:
this->IncrementLength(1);
return elem;
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -1510,6 +1533,7 @@ public:
// Append new elements without copy-constructing. This is useful to avoid
// temporaries.
// @return A pointer to the newly appended elements, or null on OOM.
protected:
template<typename ActualAlloc = Alloc>
elem_type* AppendElements(size_type aCount) {
if (!ActualAlloc::Successful(this->template EnsureCapacity<ActualAlloc>(
@ -1524,6 +1548,7 @@ public:
this->IncrementLength(aCount);
return elems;
}
public:
/* MOZ_WARN_UNUSED_RESULT */
elem_type* AppendElements(size_type aCount,
@ -1535,11 +1560,13 @@ public:
// Append a new element without copy-constructing. This is useful to avoid
// temporaries.
// @return A pointer to the newly appended element, or null on OOM.
protected:
template<typename ActualAlloc = Alloc>
elem_type* AppendElement()
{
return AppendElements<ActualAlloc>(1);
}
public:
/* MOZ_WARN_UNUSED_RESULT */
elem_type* AppendElement(const mozilla::fallible_t&)
@ -1661,12 +1688,14 @@ public:
// will not reduce the number of elements in this array.
// @param aCapacity The desired capacity of this array.
// @return True if the operation succeeded; false if we ran out of memory
protected:
template<typename ActualAlloc = Alloc>
typename ActualAlloc::ResultType SetCapacity(size_type aCapacity)
{
return ActualAlloc::Result(this->template EnsureCapacity<ActualAlloc>(
aCapacity, sizeof(elem_type)));
}
public:
/* MOZ_WARN_UNUSED_RESULT */
bool SetCapacity(size_type aCapacity, const mozilla::fallible_t&)
@ -1682,6 +1711,7 @@ public:
// @return True if the operation succeeded; false otherwise.
// See also TruncateLength if the new length is guaranteed to be smaller than
// the old.
protected:
template<typename ActualAlloc = Alloc>
typename ActualAlloc::ResultType SetLength(size_type aNewLen)
{
@ -1694,6 +1724,7 @@ public:
TruncateLength(aNewLen);
return ActualAlloc::ConvertBoolToResultType(true);
}
public:
/* MOZ_WARN_UNUSED_RESULT */
bool SetLength(size_type aNewLen, const mozilla::fallible_t&)
@ -1721,6 +1752,7 @@ public:
// constructor.
// @param aMinLen The desired minimum length of this array.
// @return True if the operation succeeded; false otherwise.
protected:
template<typename ActualAlloc = Alloc>
typename ActualAlloc::ResultType EnsureLengthAtLeast(size_type aMinLen)
{
@ -1731,6 +1763,7 @@ public:
}
return ActualAlloc::ConvertBoolToResultType(true);
}
public:
/* MOZ_WARN_UNUSED_RESULT */
bool EnsureLengthAtLeast(size_type aMinLen, const mozilla::fallible_t&)
@ -1743,6 +1776,7 @@ public:
// @param aIndex the place to insert the new elements. This must be no
// greater than the current length of the array.
// @param aCount the number of elements to insert
protected:
template<typename ActualAlloc = Alloc>
elem_type* InsertElementsAt(index_type aIndex, size_type aCount)
{
@ -1761,6 +1795,7 @@ public:
return Elements() + aIndex;
}
public:
/* MOZ_WARN_UNUSED_RESULT */
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
@ -1776,6 +1811,7 @@ public:
// greater than the current length of the array.
// @param aCount the number of elements to insert.
// @param aItem the value to use when constructing the new elements.
protected:
template<class Item, typename ActualAlloc = Alloc>
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
const Item& aItem)
@ -1795,6 +1831,7 @@ public:
return Elements() + aIndex;
}
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
@ -2049,6 +2086,17 @@ public:
base_type::operator=(mozilla::Move(aOther));
return *this;
}
using base_type::AppendElement;
using base_type::AppendElements;
using base_type::EnsureLengthAtLeast;
using base_type::InsertElementAt;
using base_type::InsertElementsAt;
using base_type::InsertElementSorted;
using base_type::MoveElementsFrom;
using base_type::ReplaceElementsAt;
using base_type::SetCapacity;
using base_type::SetLength;
};
//