From b96e0438ae30526895576a74f07d26bcddf33471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 3 Jul 2025 17:46:02 +0300 Subject: [PATCH] gstreamer: Use `from_glib_ptr_borrow()` instead of manual pointer operations Part-of: --- gstreamer/src/memory.rs | 6 +++--- gstreamer/src/message.rs | 2 +- gstreamer/src/pad_template.rs | 6 +++--- gstreamer/src/param_spec.rs | 5 +---- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/gstreamer/src/memory.rs b/gstreamer/src/memory.rs index 22376afde..d260c2257 100644 --- a/gstreamer/src/memory.rs +++ b/gstreamer/src/memory.rs @@ -8,7 +8,7 @@ use std::{ ptr, slice, }; -use glib::translate::*; +use glib::{prelude::*, translate::*}; use crate::{ffi, AllocationParams, Allocator, MemoryFlags}; @@ -126,7 +126,7 @@ impl MemoryRef { if self.0.allocator.is_null() { None } else { - Some(&*(&self.0.allocator as *const *mut ffi::GstAllocator as *const Allocator)) + Some(Allocator::from_glib_ptr_borrow(&self.0.allocator)) } } } @@ -970,7 +970,7 @@ impl MemoryRefTrace { if self.0.allocator.is_null() { None } else { - Some(&*(&self.0.allocator as *const *mut ffi::GstAllocator as *const Allocator)) + Some(Allocator::from_glib_ptr_borrow(&self.0.allocator)) } } } diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index c34c136a6..bf64f0d37 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -28,7 +28,7 @@ impl MessageRef { if (*self.as_ptr()).src.is_null() { None } else { - Some(&*(&(*self.as_ptr()).src as *const *mut ffi::GstObject as *const Object)) + Some(Object::from_glib_ptr_borrow(&(*self.as_ptr()).src)) } } } diff --git a/gstreamer/src/pad_template.rs b/gstreamer/src/pad_template.rs index 2d9bb262d..6a9f14276 100644 --- a/gstreamer/src/pad_template.rs +++ b/gstreamer/src/pad_template.rs @@ -29,7 +29,7 @@ impl PadTemplate { pub fn caps(&self) -> &Caps { unsafe { let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate); - &*(&templ.caps as *const *mut ffi::GstCaps as *const Caps) + Caps::from_glib_ptr_borrow(&templ.caps) } } @@ -41,9 +41,9 @@ impl PadTemplate { unsafe { let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate); if !templ.ABI.abi.documentation_caps.is_null() { - &*(&templ.ABI.abi.documentation_caps as *const *mut ffi::GstCaps as *const Caps) + Caps::from_glib_ptr_borrow(&templ.ABI.abi.documentation_caps) } else { - &*(&templ.caps as *const *mut ffi::GstCaps as *const Caps) + self.caps() } } } diff --git a/gstreamer/src/param_spec.rs b/gstreamer/src/param_spec.rs index ec8b3b822..3809c7c23 100644 --- a/gstreamer/src/param_spec.rs +++ b/gstreamer/src/param_spec.rs @@ -277,10 +277,7 @@ impl ParamSpecArray { if (*ptr).element_spec.is_null() { None } else { - Some( - &*(&(*ptr).element_spec as *const *mut glib::gobject_ffi::GParamSpec - as *const glib::ParamSpec), - ) + Some(glib::ParamSpec::from_glib_ptr_borrow(&(*ptr).element_spec)) } } }