diff options
-rw-r--r-- | Kernel/PerformanceEventBuffer.cpp | 4 | ||||
-rw-r--r-- | Kernel/PerformanceEventBuffer.h | 9 |
2 files changed, 9 insertions, 4 deletions
diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index 2a96bf22b5..51c35c051e 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -33,7 +33,7 @@ namespace Kernel { 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) { ASSERT(index < capacity()); - auto* events = reinterpret_cast<PerformanceEvent*>(m_buffer.data()); + auto* events = reinterpret_cast<PerformanceEvent*>(m_buffer->data()); return events[index]; } diff --git a/Kernel/PerformanceEventBuffer.h b/Kernel/PerformanceEventBuffer.h index 25750baaa7..4d5ca2ed70 100644 --- a/Kernel/PerformanceEventBuffer.h +++ b/Kernel/PerformanceEventBuffer.h @@ -61,7 +61,12 @@ public: 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; } const PerformanceEvent& at(size_t index) const { @@ -74,7 +79,7 @@ private: PerformanceEvent& at(size_t index); size_t m_count { 0 }; - KBuffer m_buffer; + OwnPtr<KBuffer> m_buffer; }; } |