Skip to content

Commit 9b8feeb

Browse files
committed
Use Box::leak to get pointer to data.
1 parent c73b81e commit 9b8feeb

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

rust/kernel/sync/arc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ impl<T: RefCounted> Ref<T> {
5151
pub fn try_new(contents: T) -> KernelResult<Self> {
5252
let boxed = Box::try_new(contents)?;
5353
boxed.get_count().count.store(1, Ordering::Relaxed);
54-
let ptr = NonNull::from(boxed.deref());
55-
Box::into_raw(boxed);
54+
let ptr = NonNull::from(Box::leak(boxed));
5655
Ok(Ref { ptr })
5756
}
5857
}

0 commit comments

Comments
 (0)