From 399f3697b5468af6f827af4f8a856aa842d7c2b6 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 19 Nov 2025 03:16:11 +0100 Subject: feat: making usage of the OCL way easier. Signed-off-by: Amlal El Mahrouss --- dev/lib/memory/allocator_system.hpp | 10 +++++----- dev/lib/memory/tracked_ptr.hpp | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'dev/lib/memory') diff --git a/dev/lib/memory/allocator_system.hpp b/dev/lib/memory/allocator_system.hpp index 1873064..81cd34f 100644 --- a/dev/lib/memory/allocator_system.hpp +++ b/dev/lib/memory/allocator_system.hpp @@ -40,8 +40,8 @@ namespace ocl template class allocator_system { - allocator_new alloc_; - allocator_delete del_; + allocator_new m_alloc_{}; + allocator_delete m_free_{}; public: allocator_system() = default; @@ -52,18 +52,18 @@ namespace ocl ret_type* claim() noexcept { - return alloc_(); + return m_alloc_(); } template auto construct(var_type... args) -> std::shared_ptr { - return std::shared_ptr(alloc_.template var_alloc(args...), allocator_delete{}); + return std::shared_ptr(m_alloc_.template var_alloc(args...), allocator_delete{}); } void unclaim(ret_type* ptr) { - del_(ptr); + m_free_(ptr); } }; diff --git a/dev/lib/memory/tracked_ptr.hpp b/dev/lib/memory/tracked_ptr.hpp index 61daada..bf557d8 100644 --- a/dev/lib/memory/tracked_ptr.hpp +++ b/dev/lib/memory/tracked_ptr.hpp @@ -140,7 +140,7 @@ namespace ocl::memory this->reset(); } - tracked_ptr(const tracked_ptr&) = delete; + tracked_ptr(const tracked_ptr&) = delete; tracked_ptr& operator=(const tracked_ptr&) = delete; public: @@ -224,12 +224,12 @@ namespace ocl::memory } /// @brief a Must Pass function is a standard way to verify a container' validity, inspired from NeKernel/VMKernel. - template - inline void must_pass(tracked_ptr& ptr) noexcept + template + inline void must_pass(tracked_ptr& ptr, error_handler handler) { if (ptr.manager().allocator().allocated_count_ < ptr.manager().allocator().deallocated_count_) { - ::kill(::getpid(), SIGTRAP); + handler.template error("Invalid TrackedPtr detected: Deallocated count exceeds allocated count."); } } } // namespace ocl::memory -- cgit v1.2.3