mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-08-22 10:18:48 +00:00
Formatting
This commit is contained in:
parent
0b60559b34
commit
b7b245a7b0
1 changed files with 26 additions and 27 deletions
53
third_party/host_memory/virtual_buffer.cpp
vendored
53
third_party/host_memory/virtual_buffer.cpp
vendored
|
@ -10,38 +10,37 @@
|
||||||
#include "host_memory/virtual_buffer.h"
|
#include "host_memory/virtual_buffer.h"
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
void* AllocateMemoryPages(std::size_t size) noexcept {
|
||||||
void* AllocateMemoryPages(std::size_t size) noexcept {
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
void* base{VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE)};
|
void* base{VirtualAlloc(nullptr, size, MEM_COMMIT, PAGE_READWRITE)};
|
||||||
#else
|
#else
|
||||||
void* base{mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0)};
|
void* base{mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0)};
|
||||||
|
|
||||||
if (base == MAP_FAILED) {
|
if (base == MAP_FAILED) {
|
||||||
base = nullptr;
|
base = nullptr;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!base) {
|
if (!base) {
|
||||||
Helpers::panic("Failed to allocate memory pages");
|
Helpers::panic("Failed to allocate memory pages");
|
||||||
}
|
}
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
}
|
|
||||||
|
|
||||||
void FreeMemoryPages(void* base, [[maybe_unused]] std::size_t size) noexcept {
|
|
||||||
if (!base) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (!VirtualFree(base, 0, MEM_RELEASE)) {
|
|
||||||
Helpers::panic("Failed to free memory pages");
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
if (munmap(base, size) != 0) {
|
|
||||||
Helpers::panic("Failed to free memory pages");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Common
|
void FreeMemoryPages(void* base, [[maybe_unused]] std::size_t size) noexcept {
|
||||||
|
if (!base) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef _WIN32
|
||||||
|
if (!VirtualFree(base, 0, MEM_RELEASE)) {
|
||||||
|
Helpers::panic("Failed to free memory pages");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if (munmap(base, size) != 0) {
|
||||||
|
Helpers::panic("Failed to free memory pages");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Common
|
Loading…
Add table
Add a link
Reference in a new issue