mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
gstreamer,video: Do not zero-initialize designated struct members
This should be analogous to C struct initalizers where all unspecified fields are initialized to zero. Without mut this reads a bit nicer as well. Note that two out of three structs have all members specified, hence need no zero-initialization of the remainder at all.
This commit is contained in:
parent
89c7883202
commit
ce67076f26
3 changed files with 18 additions and 27 deletions
|
@ -59,16 +59,12 @@ impl VideoAlignment {
|
|||
) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
let videoalignment = unsafe {
|
||||
let mut videoalignment: ffi::GstVideoAlignment = mem::zeroed();
|
||||
|
||||
videoalignment.padding_top = padding_top;
|
||||
videoalignment.padding_bottom = padding_bottom;
|
||||
videoalignment.padding_left = padding_left;
|
||||
videoalignment.padding_right = padding_right;
|
||||
videoalignment.stride_align = *stride_align;
|
||||
|
||||
videoalignment
|
||||
let videoalignment = ffi::GstVideoAlignment {
|
||||
padding_top,
|
||||
padding_bottom,
|
||||
padding_left,
|
||||
padding_right,
|
||||
stride_align: *stride_align,
|
||||
};
|
||||
|
||||
VideoAlignment(videoalignment)
|
||||
|
|
|
@ -84,15 +84,11 @@ impl VideoColorimetry {
|
|||
) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
let colorimetry = unsafe {
|
||||
let mut colorimetry: ffi::GstVideoColorimetry = mem::zeroed();
|
||||
|
||||
colorimetry.range = range.to_glib();
|
||||
colorimetry.matrix = matrix.to_glib();
|
||||
colorimetry.transfer = transfer.to_glib();
|
||||
colorimetry.primaries = primaries.to_glib();
|
||||
|
||||
colorimetry
|
||||
let colorimetry = ffi::GstVideoColorimetry {
|
||||
range: range.to_glib(),
|
||||
matrix: matrix.to_glib(),
|
||||
transfer: transfer.to_glib(),
|
||||
primaries: primaries.to_glib(),
|
||||
};
|
||||
|
||||
VideoColorimetry(colorimetry)
|
||||
|
|
|
@ -32,14 +32,13 @@ impl AllocationParams {
|
|||
pub fn new(flags: MemoryFlags, align: usize, prefix: usize, padding: usize) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
let allocationparams = unsafe {
|
||||
let mut allocationparams: ffi::GstAllocationParams = mem::zeroed();
|
||||
|
||||
allocationparams.flags = flags.to_glib();
|
||||
allocationparams.align = align;
|
||||
allocationparams.prefix = prefix;
|
||||
allocationparams.padding = padding;
|
||||
|
||||
allocationparams
|
||||
ffi::GstAllocationParams {
|
||||
flags: flags.to_glib(),
|
||||
align,
|
||||
prefix,
|
||||
padding,
|
||||
..mem::zeroed()
|
||||
}
|
||||
};
|
||||
|
||||
AllocationParams(allocationparams)
|
||||
|
|
Loading…
Reference in a new issue