A Mapping like NonOwnedMapping, but uses Free as its release proc.
More...
#include <mapping.h>
A Mapping like NonOwnedMapping, but uses Free as its release proc.
Definition at line 144 of file mapping.h.
◆ MallocMapping() [1/3]
fml::MallocMapping::MallocMapping |
( |
| ) |
|
Definition at line 119 of file mapping.cc.
119: data_(nullptr), size_(0) {}
◆ MallocMapping() [2/3]
fml::MallocMapping::MallocMapping |
( |
uint8_t * |
data, |
|
|
size_t |
size |
|
) |
| |
Creates a MallocMapping for a region of memory (without copying it). The function will abort()
if the malloc fails.
- Parameters
-
data | The starting address of the mapping. |
size | The size of the mapping in bytes. |
Definition at line 121 of file mapping.cc.
constexpr std::size_t size(T(&array)[N])
std::shared_ptr< const fml::Mapping > data
◆ MallocMapping() [3/3]
Definition at line 124 of file mapping.cc.
125 : data_(mapping.data_), size_(mapping.size_) {
126 mapping.data_ = nullptr;
127 mapping.size_ = 0;
128}
◆ ~MallocMapping()
fml::MallocMapping::~MallocMapping |
( |
| ) |
|
|
override |
Definition at line 130 of file mapping.cc.
130 {
131 free(data_);
132 data_ = nullptr;
133}
◆ Copy() [1/2]
static MallocMapping fml::MallocMapping::Copy |
( |
const T * |
begin, |
|
|
const T * |
end |
|
) |
| |
|
inlinestatic |
Copies the data from begin
to end
. It's templated since void* arithemetic isn't allowed and we want support for uint8_t
and char
.
Definition at line 162 of file mapping.h.
162 {
166 }
static MallocMapping Copy(const T *begin, const T *end)
static const char * begin(const StringSlice &s)
#define FML_DCHECK(condition)
◆ Copy() [2/2]
MallocMapping fml::MallocMapping::Copy |
( |
const void * |
begin, |
|
|
size_t |
length |
|
) |
| |
|
static |
Copies a region of memory into a MallocMapping. The function will abort()
if the malloc fails.
- Parameters
-
begin | The starting address of where we will copy. |
length | The length of the region to copy in bytes. |
Definition at line 135 of file mapping.cc.
135 {
141}
#define FML_CHECK(condition)
void * malloc(size_t size)
◆ GetMapping()
const uint8_t * fml::MallocMapping::GetMapping |
( |
| ) |
const |
|
overridevirtual |
◆ GetSize()
size_t fml::MallocMapping::GetSize |
( |
| ) |
const |
|
overridevirtual |
◆ IsDontNeedSafe()
bool fml::MallocMapping::IsDontNeedSafe |
( |
| ) |
const |
|
overridevirtual |
◆ Release()
uint8_t * fml::MallocMapping::Release |
( |
| ) |
|
Removes ownership of the data buffer. After this is called; the mapping will point to nullptr.
Definition at line 155 of file mapping.cc.
155 {
157 data_ = nullptr;
158 size_ = 0;
160}
The documentation for this class was generated from the following files: