15ffd83dbSDimitry Andric //===-- DataBufferLLVM.cpp ------------------------------------------------===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #include "lldb/Utility/DataBufferLLVM.h"
10*0b57cec5SDimitry Andric 
11*0b57cec5SDimitry Andric #include "llvm/Support/MemoryBuffer.h"
12*0b57cec5SDimitry Andric 
13*0b57cec5SDimitry Andric #include <assert.h>
14*0b57cec5SDimitry Andric 
15*0b57cec5SDimitry Andric using namespace lldb_private;
16*0b57cec5SDimitry Andric 
17*0b57cec5SDimitry Andric DataBufferLLVM::DataBufferLLVM(
18*0b57cec5SDimitry Andric     std::unique_ptr<llvm::WritableMemoryBuffer> MemBuffer)
19*0b57cec5SDimitry Andric     : Buffer(std::move(MemBuffer)) {
20*0b57cec5SDimitry Andric   assert(Buffer != nullptr &&
21*0b57cec5SDimitry Andric          "Cannot construct a DataBufferLLVM with a null buffer");
22*0b57cec5SDimitry Andric }
23*0b57cec5SDimitry Andric 
24*0b57cec5SDimitry Andric DataBufferLLVM::~DataBufferLLVM() {}
25*0b57cec5SDimitry Andric 
26*0b57cec5SDimitry Andric uint8_t *DataBufferLLVM::GetBytes() {
27*0b57cec5SDimitry Andric   return reinterpret_cast<uint8_t *>(Buffer->getBufferStart());
28*0b57cec5SDimitry Andric }
29*0b57cec5SDimitry Andric 
30*0b57cec5SDimitry Andric const uint8_t *DataBufferLLVM::GetBytes() const {
31*0b57cec5SDimitry Andric   return reinterpret_cast<const uint8_t *>(Buffer->getBufferStart());
32*0b57cec5SDimitry Andric }
33*0b57cec5SDimitry Andric 
34*0b57cec5SDimitry Andric lldb::offset_t DataBufferLLVM::GetByteSize() const {
35*0b57cec5SDimitry Andric   return Buffer->getBufferSize();
36*0b57cec5SDimitry Andric }
37