/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Bounds check that we can safely truncate size_t `aLength` to an int. if (aLength == 0 || aLength > INT_MAX) {
MOZ_ASSERT_UNREACHABLE("Bad aLength"); returnfalse;
} int len = static_cast<int>(aLength);
// Only try to use NSS on the main thread. if (!NS_IsMainThread() || !NSS_IsInitialized()) { returnfalse;
}
mozilla::UniquePK11SlotInfo slot(PK11_GetInternalSlot()); if (!slot) {
MOZ_ASSERT_UNREACHABLE("Null slot"); returnfalse;
}
nsresult nsID::GenerateUUIDInPlace(nsID& aId) { // Firefox needs to generate some UUIDs before NSS has been initialized. We // prefer NSS's RNG, but if NSS is not available yet or returns an error, fall // back to MFBT's GenerateRandomBytes(). if (!GenerateRandomBytesFromNSS(&aId, sizeof(nsID)) &&
!mozilla::GenerateRandomBytesFromOS(&aId, sizeof(nsID))) {
MOZ_ASSERT_UNREACHABLE("GenerateRandomBytesFromOS() failed"); return NS_ERROR_NOT_AVAILABLE;
}
// Put in the version
aId.m2 &= 0x0fff;
aId.m2 |= 0x4000;
// Put in the variant
aId.m3[0] &= 0x3f;
aId.m3[0] |= 0x80;
/** * Multiplies the_int_var with 16 (0x10) and adds the value of the * hexadecimal digit the_char. If it fails it returns false from * the function it's used in.
*/
/** * Parses number_of_chars characters from the char_pointer pointer and * puts the number in the dest_variable. The pointer is moved to point * at the first character after the parsed ones. If it fails it returns * false from the function the macro is used in.
*/
/** * Parses a hyphen from the char_pointer string. If there is no hyphen there * the function returns false from the function it's used in. The * char_pointer is advanced one step.
*/
#define PARSE_HYPHEN(char_pointer) \ if (*(char_pointer++) != '-') returnfalse
/* * Turns a {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} string into * an nsID. It can also handle the old format without the { and }.
*/
bool nsID::Parse(constchar* aIDStr) { /* Optimized for speed */ if (!aIDStr) { returnfalse;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.