core/memory: Migrate over ReadCString() to the Memory class
This only had one usage spot, so this is fairly straightforward to convert over.
This commit is contained in:
parent
7110e6a128
commit
8d306269d0
3 changed files with 40 additions and 18 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue