Bug 1860073 [wpt PR 42637] - Update wpt metadata, a=testonly
[gecko.git] / xpcom / ds / nsTArray.cpp
blob50326fb331b417adff276eb661bc6531939990f2
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include <string.h>
8 #include "nsTArray.h"
9 #include "nsXPCOM.h"
10 #include "nsCycleCollectionNoteChild.h"
11 #include "nsDebug.h"
12 #include "mozilla/CheckedInt.h"
13 #include "mozilla/IntegerPrintfMacros.h"
15 // Ensure this is sufficiently aligned so that Elements() and co don't create
16 // unaligned pointers, or slices with unaligned pointers for empty arrays, see
17 // https://github.com/servo/servo/issues/22613.
18 alignas(8) const nsTArrayHeader sEmptyTArrayHeader = {0, 0, 0};
20 bool IsTwiceTheRequiredBytesRepresentableAsUint32(size_t aCapacity,
21 size_t aElemSize) {
22 using mozilla::CheckedUint32;
23 return ((CheckedUint32(aCapacity) * aElemSize) * 2).isValid();
26 void ::detail::SetCycleCollectionArrayFlag(uint32_t& aFlags) {
27 aFlags |= CycleCollectionEdgeNameArrayFlag;