diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2013-12-22 00:04:03 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2013-12-22 00:04:03 +0000 |
commit | f8af5cf600354830d4ccf59732403f0f073eccb9 (patch) | |
tree | 2ba0398b4c42ad4f55561327538044fd2c925a8b /lib/Support/StringRefMemoryObject.cpp | |
parent | 59d6cff90eecf31cb3dd860c4e786674cfdd42eb (diff) |
Notes
Diffstat (limited to 'lib/Support/StringRefMemoryObject.cpp')
-rw-r--r-- | lib/Support/StringRefMemoryObject.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Support/StringRefMemoryObject.cpp b/lib/Support/StringRefMemoryObject.cpp new file mode 100644 index 000000000000..e035ed1d2ef3 --- /dev/null +++ b/lib/Support/StringRefMemoryObject.cpp @@ -0,0 +1,29 @@ +//===- lib/Support/StringRefMemoryObject.cpp --------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Support/StringRefMemoryObject.h" + +using namespace llvm; + +int StringRefMemoryObject::readByte(uint64_t Addr, uint8_t *Byte) const { + if (Addr >= Base + getExtent() || Addr < Base) + return -1; + *Byte = Bytes[Addr - Base]; + return 0; +} + +int StringRefMemoryObject::readBytes(uint64_t Addr, + uint64_t Size, + uint8_t *Buf) const { + uint64_t Offset = Addr - Base; + if (Addr >= Base + getExtent() || Offset + Size > getExtent() || Addr < Base) + return -1; + memcpy(Buf, Bytes.data() + Offset, Size); + return 0; +} |