Skip to content

Commit

Permalink
offset_of!: Replace calls (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
kkysen authored Dec 8, 2023
2 parents 2df6b91 + fc2341e commit 64450d0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 14 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
20 changes: 11 additions & 9 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 @@ -5679,11 +5678,14 @@ 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),
);
rav1d_ref_dec(&mut (*cdf).r#ref);
pub unsafe fn rav1d_cdf_thread_unref(cdf: &mut CdfThreadContext) {
*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);
}
1 change: 0 additions & 1 deletion tests/seek_stress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(non_upper_case_globals)]
#![feature(extern_types)]
#![feature(c_variadic)]
#![feature(offset_of)]
#![allow(clippy::all)]

#[path = "../tools/input"]
Expand Down
1 change: 0 additions & 1 deletion tools/dav1d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#![allow(non_upper_case_globals)]
#![feature(extern_types)]
#![feature(c_variadic)]
#![feature(offset_of)]
#![allow(clippy::all)]

mod input {
Expand Down
2 changes: 1 addition & 1 deletion tools/input/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ pub unsafe fn input_open(
}
c = calloc(
1,
mem::offset_of!(DemuxerContext, priv_data) + (*impl_0).priv_data_size as usize,
mem::size_of::<DemuxerContext>() + (*impl_0).priv_data_size as usize,
) as *mut DemuxerContext;
if c.is_null() {
fprintf(
Expand Down
2 changes: 1 addition & 1 deletion tools/output/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ pub unsafe fn output_open(
return -ENOPROTOOPT;
}
}
c = malloc(mem::offset_of!(MuxerContext, priv_data) + (*impl_0).priv_data_size as usize)
c = malloc(mem::size_of::<MuxerContext>() + (*impl_0).priv_data_size as usize)
as *mut MuxerContext;
if c.is_null() {
fprintf(
Expand Down

0 comments on commit 64450d0

Please sign in to comment.