no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / xpcom / ds / nsTArray.cpp
blob3c193ece91fae57422d4f5299877e81105aea8f5
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 "nsTArray.h"
8 #include "nsXPCOM.h"
9 #include "nsCycleCollectionNoteChild.h"
10 #include "nsDebug.h"
11 #include "mozilla/CheckedInt.h"
12 #include "mozilla/IntegerPrintfMacros.h"
14 // Ensure this is sufficiently aligned so that Elements() and co don't create
15 // unaligned pointers, or slices with unaligned pointers for empty arrays, see
16 // https://github.com/servo/servo/issues/22613.
17 alignas(8) const nsTArrayHeader sEmptyTArrayHeader = {0, 0, 0};
19 bool IsTwiceTheRequiredBytesRepresentableAsUint32(size_t aCapacity,
20 size_t aElemSize) {
21 using mozilla::CheckedUint32;
22 return ((CheckedUint32(aCapacity) * aElemSize) * 2).isValid();
25 void ::detail::SetCycleCollectionArrayFlag(uint32_t& aFlags) {
26 aFlags |= CycleCollectionEdgeNameArrayFlag;