diff --git a/src/gallium/frontends/rusticl/api/event.rs b/src/gallium/frontends/rusticl/api/event.rs index f7eba482ea2..777e5085f62 100644 --- a/src/gallium/frontends/rusticl/api/event.rs +++ b/src/gallium/frontends/rusticl/api/event.rs @@ -162,7 +162,12 @@ pub fn create_and_queue( work: EventSig, ) -> CLResult<()> { let e = Event::new(&q, cmd_type, deps, work); - cl_event::leak_ref(event, &e); + if !event.is_null() { + // SAFETY: we check for null and valid API use is to pass in a valid pointer + unsafe { + event.write(cl_event::from_arc(Arc::clone(&e))); + } + } q.queue(e); if block { q.flush(true)?; diff --git a/src/gallium/frontends/rusticl/api/icd.rs b/src/gallium/frontends/rusticl/api/icd.rs index 6af24a4b9b7..e8a37ce600a 100644 --- a/src/gallium/frontends/rusticl/api/icd.rs +++ b/src/gallium/frontends/rusticl/api/icd.rs @@ -234,17 +234,6 @@ pub trait ReferenceCountedAPIPointer { // implement that as part of the macro where we know the real type. fn from_ptr(ptr: *const T) -> Self; - fn leak_ref(ptr: *mut Self, r: &std::sync::Arc) - where - Self: Sized, - { - if !ptr.is_null() { - unsafe { - ptr.write(Self::from_arc(r.clone())); - } - } - } - fn get_ref(&self) -> CLResult<&T> { unsafe { Ok(self.get_ptr()?.as_ref().unwrap()) } }