mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-28 18:12:44 -06:00
kernel/shared_memory: Add a const qualified member function overload for GetPointer()
Given this doesn't mutate instance state, we can provide a const-qualified variant as well.
This commit is contained in:
parent
1cb9bea504
commit
0f544af89a
2 changed files with 15 additions and 1 deletions
|
@ -196,4 +196,11 @@ u8* SharedMemory::GetPointer(u32 offset) {
|
||||||
return backing_blocks[0].first + offset;
|
return backing_blocks[0].first + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const u8* SharedMemory::GetPointer(u32 offset) const {
|
||||||
|
if (backing_blocks.size() != 1) {
|
||||||
|
LOG_WARNING(Kernel, "Unsafe GetPointer on discontinuous SharedMemory");
|
||||||
|
}
|
||||||
|
return backing_blocks[0].first + offset;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
|
@ -66,10 +66,17 @@ public:
|
||||||
/**
|
/**
|
||||||
* Gets a pointer to the shared memory block
|
* Gets a pointer to the shared memory block
|
||||||
* @param offset Offset from the start of the shared memory block to get pointer
|
* @param offset Offset from the start of the shared memory block to get pointer
|
||||||
* @return Pointer to the shared memory block from the specified offset
|
* @return A pointer to the shared memory block from the specified offset
|
||||||
*/
|
*/
|
||||||
u8* GetPointer(u32 offset = 0);
|
u8* GetPointer(u32 offset = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a constant pointer to the shared memory block
|
||||||
|
* @param offset Offset from the start of the shared memory block to get pointer
|
||||||
|
* @return A constant pointer to the shared memory block from the specified offset
|
||||||
|
*/
|
||||||
|
const u8* GetPointer(u32 offset = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit SharedMemory(KernelSystem& kernel);
|
explicit SharedMemory(KernelSystem& kernel);
|
||||||
~SharedMemory() override;
|
~SharedMemory() override;
|
||||||
|
|
Loading…
Reference in a new issue