Skip to content

Commit

Permalink
fn rav1d_cdf_thread_unref: Replace a memset with offset_of with…
Browse files Browse the repository at this point in the history
… a normal assignment with 0s.
  • Loading branch information
kkysen committed Dec 6, 2023
1 parent 6c20114 commit 1c9bfc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#![allow(non_upper_case_globals)]
#![feature(c_variadic)]
#![feature(core_intrinsics)]
#![feature(offset_of)] // TODO(kkysen) Will be removed shortly.
#![cfg_attr(target_arch = "arm", feature(stdsimd))]
#![allow(clippy::all)]

Expand Down
16 changes: 9 additions & 7 deletions src/cdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@ use crate::src::r#ref::rav1d_ref_inc;
use crate::src::r#ref::Rav1dRef;
use crate::src::tables::dav1d_partition_type_count;
use libc::memcpy;
use libc::memset;
use std::cmp;
use std::ffi::c_int;
use std::ffi::c_uint;
use std::ffi::c_void;
use std::mem;
use std::ptr;

#[repr(C)]
pub struct CdfContext {
Expand Down Expand Up @@ -5680,10 +5679,13 @@ pub unsafe fn rav1d_cdf_thread_ref(dst: *mut CdfThreadContext, src: *mut CdfThre
}

pub unsafe fn rav1d_cdf_thread_unref(cdf: &mut CdfThreadContext) {
memset(
&mut cdf.data as *mut CdfThreadContext_data as *mut c_void,
0 as c_int,
::core::mem::size_of::<CdfThreadContext>() - mem::offset_of!(CdfThreadContext, data),
);
*cdf = CdfThreadContext {
r#ref: cdf.r#ref,
data: CdfThreadContext_data {
cdf: ptr::null_mut(),
// cdf is larger than qcat, so this zeroes it
},
progress: ptr::null_mut(),
};
rav1d_ref_dec(&mut cdf.r#ref);
}

0 comments on commit 1c9bfc3

Please sign in to comment.