Bug 1295695 - Add maybe_pod_* methods to InfallibleAllocPolicy. r=glandium

Bug 1207519 added maybe_pod_* methods to the allocation policy
classes, but did not add them to InfallibleAllocPolicy.

I think the idea of these methods is that the callers are explicitly
opting into fallible behavior, so they will deal with any errors that
occur. For instance, in js::HashTable, this is used to try to shrink
the hash table when there are a lot of unused entries. If the shrink
fails, it just continues to use the existing block of memory.

However, having fallible methods in a supposedly infallible class is
weird, so for now, just use the infallible version.

MozReview-Commit-ID: 97D66Z4oLfl

--HG--
extra : rebase_source : 9a3e0b50a5602a8e4772da88c16e1715c25da7df
This commit is contained in:
Andrew McCreight 2016-08-16 11:09:05 -07:00
parent b9fe49e715
commit 5772f60634

View File

@ -289,6 +289,24 @@ void operator delete[](void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_
class InfallibleAllocPolicy
{
public:
template <typename T>
T* maybe_pod_malloc(size_t aNumElems)
{
return pod_malloc<T>(aNumElems);
}
template <typename T>
T* maybe_pod_calloc(size_t aNumElems)
{
return pod_calloc<T>(aNumElems);
}
template <typename T>
T* maybe_pod_realloc(T* aPtr, size_t aOldSize, size_t aNewSize)
{
return pod_realloc<T>(aPtr, aOldSize, aNewSize);
}
template <typename T>
T* pod_malloc(size_t aNumElems)
{