dart-sdk/runtime/vm/snapshot.cc
Ryan Macnak f9a6a5bdd2 [vm] Update NULL to nullptr in runtime/vm.
TEST=build
Change-Id: I2834ef7cf7cb7c8770f8167a2438cbedcee5c623
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292063
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-04-10 18:15:12 +00:00

45 lines
1.1 KiB
C++

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#include "vm/snapshot.h"
#include "platform/assert.h"
#include "vm/dart.h"
namespace dart {
const char* Snapshot::KindToCString(Kind kind) {
switch (kind) {
case kFull:
return "full";
case kFullCore:
return "full-core";
case kFullJIT:
return "full-jit";
case kFullAOT:
return "full-aot";
case kNone:
return "none";
case kInvalid:
default:
return "invalid";
}
}
const Snapshot* Snapshot::SetupFromBuffer(const void* raw_memory) {
ASSERT(raw_memory != nullptr);
const Snapshot* snapshot = reinterpret_cast<const Snapshot*>(raw_memory);
if (!snapshot->check_magic()) {
return nullptr;
}
// If the raw length is negative or greater than what the local machine can
// handle, then signal an error.
int64_t length = snapshot->large_length();
if ((length < 0) || (length > kIntptrMax)) {
return nullptr;
}
return snapshot;
}
} // namespace dart