nil safety for unsafe structure instances

This commit is contained in:
RSWilli
2024-11-05 11:21:52 +01:00
parent 5a9dadfbaa
commit 86976560eb

View File

@@ -94,7 +94,13 @@ func (s *Structure) UnmarshalInto(data interface{}) error {
}
// Instance returns the native GstStructure instance.
func (s *Structure) Instance() *C.GstStructure { return C.toGstStructure(s.ptr) }
func (s *Structure) Instance() *C.GstStructure {
if s == nil {
return nil
}
return C.toGstStructure(s.ptr)
}
// Free frees the memory for the underlying GstStructure.
func (s *Structure) Free() { C.gst_structure_free(s.Instance()) }