зеркало из https://github.com/mozilla/pjs.git
Bug 701210 - nsTArray::SizeOf() should use malloc_usable_size. r=roc
This commit is contained in:
Родитель
9c01db357b
Коммит
ec4a516551
|
@ -442,6 +442,7 @@ public:
|
|||
typedef nsTArray_SafeElementAtHelper<E, self_type> safeelementat_helper_type;
|
||||
|
||||
using safeelementat_helper_type::SafeElementAt;
|
||||
using base_type::EmptyHdr;
|
||||
|
||||
// A special value that is used to indicate an invalid or unknown index
|
||||
// into the array.
|
||||
|
@ -515,10 +516,13 @@ public:
|
|||
}
|
||||
|
||||
// @return The amount of memory taken used by this nsTArray, not including
|
||||
// sizeof(this)
|
||||
// sizeof(*this).
|
||||
size_t SizeOf() const {
|
||||
return this->UsesAutoArrayBuffer() ?
|
||||
0 : this->Capacity() * sizeof(elem_type) + sizeof(*this->Hdr());
|
||||
if (this->UsesAutoArrayBuffer() || Hdr() == EmptyHdr())
|
||||
return 0;
|
||||
size_t usable = moz_malloc_usable_size(this->Hdr());
|
||||
return usable ? usable :
|
||||
this->Capacity() * sizeof(elem_type) + sizeof(*this->Hdr());
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче