Skip to content

Commit 2a2d5a5

Browse files
committed
Fix
1 parent dc8b21f commit 2a2d5a5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

unity-native-plugin/src/profiler.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use std::marker::PhantomData;
21
use std::ptr::null_mut;
32
use crate::define_unity_interface;
43
use crate::interface::UnityInterface;
@@ -380,19 +379,19 @@ define_unity_interface!(
380379
pub type ProfilerCounterStatePtrCallback = UnityProfilerCounterStatePtrCallback;
381380

382381
pub struct ProfilerCounter<T> {
383-
pub(crate) counter: *mut ::std::os::raw::c_void,
382+
pub(crate) counter: *mut T,
384383
}
385384

386385
impl<T> ProfilerCounter<T> {
387386
pub fn value(&self) -> &T {
388387
unsafe {
389-
self.counter as &T
388+
&*self.counter
390389
}
391390
}
392391

393392
pub fn value_mut(&mut self) -> &mut T {
394393
unsafe {
395-
self.counter as &mut T
394+
&mut *self.counter
396395
}
397396
}
398397
}
@@ -443,14 +442,14 @@ macro_rules! impl_profiler_v2 {
443442
user_data: *mut ::std::os::raw::c_void) -> Option<ProfilerCounter<T>> {
444443
let r = self.create_counter_value(category, name, flags, value_type, value_unit, std::mem::size_of::<T>(), counter_flags.into(), activate_func, deactivate_func, user_data);
445444
if r != null_mut() {
446-
Some(ProfilerCounter::<T> { counter: r })
445+
Some(ProfilerCounter::<T> { counter: r as *mut T })
447446
} else {
448447
None
449448
}
450449
}
451450

452451
pub unsafe fn flush_counter<T>(&self, counter: &mut ProfilerCounter<T>) {
453-
self.flush_counter_value(counter.counter);
452+
self.flush_counter_value(counter.counter as *mut ::std::os::raw::c_void);
454453
}
455454
}
456455
}

0 commit comments

Comments
 (0)