diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-06-12 17:31:48 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-06-12 17:31:48 +0200 |
commit | 0f317186de9fb11d336e564f808e4732386c4074 (patch) | |
tree | b7718d9beb5bee7682649eaee021fabd6dea8668 /modules/remote-sycl | |
parent | e2a7609028346c3b776a424c9be848e49d3a0e2e (diff) |
Fix for double free
Diffstat (limited to 'modules/remote-sycl')
-rw-r--r-- | modules/remote-sycl/c++/remote.hpp | 34 |
1 files changed, 34 insertions, 0 deletions
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<Schema, encode::Native, rmt::Sycl>& from): + total_length_{from.size()}, + device_data_{nullptr}, + queue_{from.queue_} + { + if(total_length_ == 0u || !queue_){ + return; + } + device_data_ = cl::sycl::malloc_device<typename native_data_type<T>::type>(from.size(), *queue_); + if(!device_data_){ + total_length_ = 0u; + } + } + + data(data<Schema, encode::Native, rmt::Sycl>&& 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<Schema, encode::Native, rmt::Sycl>& operator=(data<Schema, encode::Native, rmt::Sycl>&& 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 |