rusticl/icd: fold leak_ref into its only consumer

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27376>
This commit is contained in:
Karol Herbst 2024-01-28 17:48:15 +01:00 committed by Marge Bot
parent 4ca11d5f06
commit 13241264f1
2 changed files with 6 additions and 12 deletions

View file

@ -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)?;

View file

@ -234,17 +234,6 @@ pub trait ReferenceCountedAPIPointer<T, const ERR: i32> {
// 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<T>)
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()) }
}