diff options
author | Lioncash <mathew1800@gmail.com> | 2019-11-26 15:48:19 -0500 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-11-26 21:55:38 -0500 |
commit | b2165c6b353be5e8117d1f9bc677bb198fa9d8cd (patch) | |
tree | 1b08113cf73a864c7c3e74cd4a3e1cca53879ce2 /src/core/memory.cpp | |
parent | 3f08e8d8d4ef16cf2468620fbfbdac46e43dcaef (diff) |
core/memory: Migrate over ReadCString() to the Memory class
This only had one usage spot, so this is fairly straightforward to
convert over.
Diffstat (limited to 'src/core/memory.cpp')
-rw-r--r-- | src/core/memory.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 93cd67e39a..fb824d7103 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -210,6 +210,21 @@ struct Memory::Impl { return nullptr; } + std::string ReadCString(VAddr vaddr, std::size_t max_length) { + std::string string; + string.reserve(max_length); + for (std::size_t i = 0; i < max_length; ++i) { + const char c = Read8(vaddr); + if (c == '\0') { + break; + } + string.push_back(c); + ++vaddr; + } + string.shrink_to_fit(); + return string; + } + /** * Maps a region of pages as a specific type. * @@ -299,6 +314,10 @@ const u8* Memory::GetPointer(VAddr vaddr) const { return impl->GetPointer(vaddr); } +std::string Memory::ReadCString(VAddr vaddr, std::size_t max_length) { + return impl->ReadCString(vaddr, max_length); +} + void SetCurrentPageTable(Kernel::Process& process) { current_page_table = &process.VMManager().page_table; @@ -315,20 +334,6 @@ bool IsKernelVirtualAddress(const VAddr vaddr) { return KERNEL_REGION_VADDR <= vaddr && vaddr < KERNEL_REGION_END; } -std::string ReadCString(VAddr vaddr, std::size_t max_length) { - std::string string; - string.reserve(max_length); - for (std::size_t i = 0; i < max_length; ++i) { - char c = Read8(vaddr); - if (c == '\0') - break; - string.push_back(c); - ++vaddr; - } - string.shrink_to_fit(); - return string; -} - void RasterizerMarkRegionCached(VAddr vaddr, u64 size, bool cached) { if (vaddr == 0) { return; |