зеркало из https://github.com/mozilla/gecko-dev.git
Bug 968520 - Add fallible variants of nsTArray::AppendElements. r=froydnj
This commit is contained in:
Родитель
c35f90a82e
Коммит
538dcc1d39
|
@ -1411,10 +1411,10 @@ 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.
|
||||
template<class Item>
|
||||
template<class Item, typename ActualAlloc = Alloc>
|
||||
elem_type* AppendElements(const Item* aArray, size_type aArrayLen)
|
||||
{
|
||||
if (!Alloc::Successful(this->template EnsureCapacity<Alloc>(
|
||||
if (!ActualAlloc::Successful(this->template EnsureCapacity<ActualAlloc>(
|
||||
Length() + aArrayLen, sizeof(elem_type)))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1424,11 +1424,27 @@ public:
|
|||
return Elements() + len;
|
||||
}
|
||||
|
||||
template<class Item>
|
||||
/* MOZ_WARN_UNUSED_RESULT */
|
||||
elem_type* AppendElements(const Item* aArray, size_type aArrayLen,
|
||||
const mozilla::fallible_t&)
|
||||
{
|
||||
return AppendElements<Item, FallibleAlloc>(aArray, aArrayLen);
|
||||
}
|
||||
|
||||
// A variation on the AppendElements method defined above.
|
||||
template<class Item, class Allocator>
|
||||
template<class Item, class Allocator, typename ActualAlloc = Alloc>
|
||||
elem_type* AppendElements(const nsTArray_Impl<Item, Allocator>& aArray)
|
||||
{
|
||||
return AppendElements(aArray.Elements(), aArray.Length());
|
||||
return AppendElements<Item, ActualAlloc>(aArray.Elements(), aArray.Length());
|
||||
}
|
||||
|
||||
template<class Item, class Allocator>
|
||||
/* MOZ_WARN_UNUSED_RESULT */
|
||||
elem_type* AppendElements(const nsTArray_Impl<Item, Allocator>& aArray,
|
||||
const mozilla::fallible_t&)
|
||||
{
|
||||
return AppendElements<Item, Allocator, FallibleAlloc>(aArray);
|
||||
}
|
||||
|
||||
// Append a new element, move constructing if possible.
|
||||
|
@ -1448,9 +1464,9 @@ 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.
|
||||
elem_type* AppendElements(size_type aCount)
|
||||
{
|
||||
if (!Alloc::Successful(this->template EnsureCapacity<Alloc>(
|
||||
template<typename ActualAlloc = Alloc>
|
||||
elem_type* AppendElements(size_type aCount) {
|
||||
if (!ActualAlloc::Successful(this->template EnsureCapacity<ActualAlloc>(
|
||||
Length() + aCount, sizeof(elem_type)))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1463,6 +1479,13 @@ public:
|
|||
return elems;
|
||||
}
|
||||
|
||||
/* MOZ_WARN_UNUSED_RESULT */
|
||||
elem_type* AppendElements(size_type aCount,
|
||||
const mozilla::fallible_t&)
|
||||
{
|
||||
return AppendElements<FallibleAlloc>(aCount);
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
Загрузка…
Ссылка в новой задаче