From 0f317186de9fb11d336e564f808e4732386c4074 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 12 Jun 2024 17:31:48 +0200 Subject: Fix for double free --- modules/remote-sycl/c++/remote.hpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'modules/remote-sycl/c++/remote.hpp') diff --git a/modules/remote-sycl/c++/remote.hpp b/modules/remote-sycl/c++/remote.hpp index a2b5a87..677a427 100644 --- a/modules/remote-sycl/c++/remote.hpp +++ b/modules/remote-sycl/c++/remote.hpp @@ -96,6 +96,40 @@ public: total_length_ = 0u; } } + + data(const data& from): + total_length_{from.size()}, + device_data_{nullptr}, + queue_{from.queue_} + { + if(total_length_ == 0u || !queue_){ + return; + } + device_data_ = cl::sycl::malloc_device::type>(from.size(), *queue_); + if(!device_data_){ + total_length_ = 0u; + } + } + + data(data&& rhs): + total_length_{rhs.total_length_}, + device_data_{rhs.device_data_}, + queue_{rhs.queue_} + { + rhs.total_length_ = 0u; + rhs.device_data_ = nullptr; + rhs.queue_ = nullptr; + } + + data& operator=(data&& rhs){ + total_length_ = rhs.total_length_; + device_data_ = rhs.device_data_; + queue_ = rhs.queue_; + rhs.total_length_ = 0u; + rhs.device_data_ = nullptr; + rhs.queue_ = nullptr; + return *this; + } ~data(){ // free data -- cgit v1.2.3