/src/mozilla-central/xpcom/ds/nsTArray.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #include <string.h> |
8 | | #include "nsTArray.h" |
9 | | #include "nsXPCOM.h" |
10 | | #include "nsDebug.h" |
11 | | #include "mozilla/CheckedInt.h" |
12 | | #include "mozilla/IntegerPrintfMacros.h" |
13 | | |
14 | | nsTArrayHeader sEmptyTArrayHeader = { 0, 0, 0 }; |
15 | | |
16 | | bool |
17 | | IsTwiceTheRequiredBytesRepresentableAsUint32(size_t aCapacity, size_t aElemSize) |
18 | 1.01M | { |
19 | 1.01M | using mozilla::CheckedUint32; |
20 | 1.01M | return ((CheckedUint32(aCapacity) * aElemSize) * 2).isValid(); |
21 | 1.01M | } |
22 | | |
23 | | MOZ_NORETURN MOZ_COLD void |
24 | | InvalidArrayIndex_CRASH(size_t aIndex, size_t aLength) |
25 | 0 | { |
26 | 0 | MOZ_CRASH_UNSAFE_PRINTF( |
27 | 0 | "ElementAt(aIndex = %" PRIu64 ", aLength = %" PRIu64 ")", |
28 | 0 | static_cast<uint64_t>(aIndex), static_cast<uint64_t>(aLength)); |
29 | 0 | } |