mirror of
https://github.com/wiiu-env/WiiUPluginLoaderBackend.git
synced 2024-12-26 12:51:52 +01:00
32 lines
901 B
C++
32 lines
901 B
C++
#include "HeapMemoryFixedSize.h"
|
|
#include "utils.h"
|
|
|
|
HeapMemoryFixedSize::HeapMemoryFixedSize() = default;
|
|
|
|
HeapMemoryFixedSize::HeapMemoryFixedSize(std::size_t size) : mData(make_unique_nothrow<uint8_t[]>(size)), mSize(mData ? size : 0) {}
|
|
|
|
HeapMemoryFixedSize::HeapMemoryFixedSize(HeapMemoryFixedSize &&other) noexcept
|
|
: mData(std::move(other.mData)), mSize(other.mSize) {
|
|
other.mSize = 0;
|
|
}
|
|
|
|
HeapMemoryFixedSize &HeapMemoryFixedSize::operator=(HeapMemoryFixedSize &&other) noexcept {
|
|
if (this != &other) {
|
|
mData = std::move(other.mData);
|
|
mSize = other.mSize;
|
|
other.mSize = 0;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
HeapMemoryFixedSize::operator bool() const {
|
|
return mData != nullptr;
|
|
}
|
|
|
|
[[nodiscard]] const void *HeapMemoryFixedSize::data() const {
|
|
return mData.get();
|
|
}
|
|
|
|
[[nodiscard]] std::size_t HeapMemoryFixedSize::size() const {
|
|
return mSize;
|
|
} |