mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:47:35 +00:00
Kernel: Use fallible KBuffer API in PerformanceEventBuffer
This commit is contained in:
parent
fb9a71bd6a
commit
d893498e57
2 changed files with 9 additions and 4 deletions
|
@ -33,7 +33,7 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
PerformanceEventBuffer::PerformanceEventBuffer()
|
PerformanceEventBuffer::PerformanceEventBuffer()
|
||||||
: m_buffer(KBuffer::create_with_size(4 * MiB))
|
: m_buffer(KBuffer::try_create_with_size(4 * MiB))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ KResult PerformanceEventBuffer::append(int type, FlatPtr arg1, FlatPtr arg2)
|
||||||
PerformanceEvent& PerformanceEventBuffer::at(size_t index)
|
PerformanceEvent& PerformanceEventBuffer::at(size_t index)
|
||||||
{
|
{
|
||||||
ASSERT(index < capacity());
|
ASSERT(index < capacity());
|
||||||
auto* events = reinterpret_cast<PerformanceEvent*>(m_buffer.data());
|
auto* events = reinterpret_cast<PerformanceEvent*>(m_buffer->data());
|
||||||
return events[index];
|
return events[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,12 @@ public:
|
||||||
|
|
||||||
KResult append(int type, FlatPtr arg1, FlatPtr arg2);
|
KResult append(int type, FlatPtr arg1, FlatPtr arg2);
|
||||||
|
|
||||||
size_t capacity() const { return m_buffer.size() / sizeof(PerformanceEvent); }
|
size_t capacity() const
|
||||||
|
{
|
||||||
|
if (!m_buffer)
|
||||||
|
return 0;
|
||||||
|
return m_buffer->size() / sizeof(PerformanceEvent);
|
||||||
|
}
|
||||||
size_t count() const { return m_count; }
|
size_t count() const { return m_count; }
|
||||||
const PerformanceEvent& at(size_t index) const
|
const PerformanceEvent& at(size_t index) const
|
||||||
{
|
{
|
||||||
|
@ -74,7 +79,7 @@ private:
|
||||||
PerformanceEvent& at(size_t index);
|
PerformanceEvent& at(size_t index);
|
||||||
|
|
||||||
size_t m_count { 0 };
|
size_t m_count { 0 };
|
||||||
KBuffer m_buffer;
|
OwnPtr<KBuffer> m_buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue