зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1292618: Add Gecko_ClearPODTArray to clear arrays of types without destructors. r=heycam
MozReview-Commit-ID: 3RRvrXn6ZTD
This commit is contained in:
Родитель
bcc13a32eb
Коммит
242a6e6bcf
|
@ -709,10 +709,24 @@ Gecko_CreateGradient(uint8_t aShape,
|
|||
void
|
||||
Gecko_EnsureTArrayCapacity(void* aArray, size_t aCapacity, size_t aElemSize)
|
||||
{
|
||||
auto base = reinterpret_cast<nsTArray_base<nsTArrayInfallibleAllocator, nsTArray_CopyWithMemutils> *>(aArray);
|
||||
auto base =
|
||||
reinterpret_cast<nsTArray_base<nsTArrayInfallibleAllocator,
|
||||
nsTArray_CopyWithMemutils> *>(aArray);
|
||||
|
||||
base->EnsureCapacity<nsTArrayInfallibleAllocator>(aCapacity, aElemSize);
|
||||
}
|
||||
|
||||
void
|
||||
Gecko_ClearPODTArray(void* aArray, size_t aElementSize, size_t aElementAlign)
|
||||
{
|
||||
auto base =
|
||||
reinterpret_cast<nsTArray_base<nsTArrayInfallibleAllocator,
|
||||
nsTArray_CopyWithMemutils> *>(aArray);
|
||||
|
||||
base->template ShiftData<nsTArrayInfallibleAllocator>(0, base->Length(), 0,
|
||||
aElementSize, aElementAlign);
|
||||
}
|
||||
|
||||
void
|
||||
Gecko_EnsureImageLayersLength(nsStyleImageLayers* aLayers, size_t aLen)
|
||||
{
|
||||
|
|
|
@ -225,6 +225,11 @@ void Gecko_StoreStyleDifference(RawGeckoNode* node, nsChangeHint change);
|
|||
// friend function declaration in nsTArray.h
|
||||
void Gecko_EnsureTArrayCapacity(void* array, size_t capacity, size_t elem_size);
|
||||
|
||||
// Same here, `array` must be an nsTArray<T>, for some T.
|
||||
//
|
||||
// Important note: Only valid for POD types, since destructors won't be run
|
||||
// otherwise. This is ensured with rust traits for the relevant structs.
|
||||
void Gecko_ClearPODTArray(void* array, size_t elem_size, size_t elem_align);
|
||||
|
||||
void Gecko_EnsureImageLayersLength(nsStyleImageLayers* layers, size_t len);
|
||||
|
||||
|
|
|
@ -328,7 +328,13 @@ struct nsTArray_SafeElementAtHelper<mozilla::OwningNonNull<E>, Derived>
|
|||
}
|
||||
};
|
||||
|
||||
extern "C" void Gecko_EnsureTArrayCapacity(void* aArray, size_t aCapacity, size_t aElemSize);
|
||||
// Servo bindings.
|
||||
extern "C" void Gecko_EnsureTArrayCapacity(void* aArray,
|
||||
size_t aCapacity,
|
||||
size_t aElementSize);
|
||||
extern "C" void Gecko_ClearPODTArray(void* aArray,
|
||||
size_t aElementSize,
|
||||
size_t aElementAlign);
|
||||
|
||||
MOZ_NORETURN MOZ_COLD void
|
||||
InvalidArrayIndex_CRASH(size_t aIndex, size_t aLength);
|
||||
|
@ -346,7 +352,10 @@ class nsTArray_base
|
|||
// the same free().
|
||||
template<class Allocator, class Copier>
|
||||
friend class nsTArray_base;
|
||||
friend void Gecko_EnsureTArrayCapacity(void* aArray, size_t aCapacity, size_t aElemSize);
|
||||
friend void Gecko_EnsureTArrayCapacity(void* aArray, size_t aCapacity,
|
||||
size_t aElemSize);
|
||||
friend void Gecko_ClearPODTArray(void* aTArray, size_t aElementSize,
|
||||
size_t aElementAlign);
|
||||
|
||||
protected:
|
||||
typedef nsTArrayHeader Header;
|
||||
|
|
Загрузка…
Ссылка в новой задаче