Make StrongRuleNode::from_ptr be unsafe

This commit is contained in:
Anthony Ramine 2020-04-16 14:34:24 +02:00
parent e5cb3d2a4c
commit 05accaa7bd

View file

@ -361,10 +361,10 @@ impl StrongRuleNode {
debug!("Creating rule node: {:p}", ptr); debug!("Creating rule node: {:p}", ptr);
StrongRuleNode::from_ptr(ptr) unsafe { StrongRuleNode::from_ptr(ptr) }
} }
fn from_ptr(p: ptr::NonNull<RuleNode>) -> Self { unsafe fn from_ptr(p: ptr::NonNull<RuleNode>) -> Self {
StrongRuleNode { p } StrongRuleNode { p }
} }
@ -413,7 +413,7 @@ impl StrongRuleNode {
}, },
); );
StrongRuleNode::from_ptr(weak.p) unsafe { StrongRuleNode::from_ptr(weak.p) }
} }
/// Raw pointer to the RuleNode /// Raw pointer to the RuleNode
@ -606,7 +606,7 @@ impl Clone for StrongRuleNode {
); );
debug_assert!(self.get().refcount.load(Ordering::Relaxed) > 0); debug_assert!(self.get().refcount.load(Ordering::Relaxed) > 0);
self.get().refcount.fetch_add(1, Ordering::Relaxed); self.get().refcount.fetch_add(1, Ordering::Relaxed);
StrongRuleNode::from_ptr(self.p) unsafe { StrongRuleNode::from_ptr(self.p) }
} }
} }
@ -767,7 +767,7 @@ impl WeakRuleNode {
let node = unsafe { &*self.ptr() }; let node = unsafe { &*self.ptr() };
node.refcount.fetch_add(1, Ordering::Relaxed); node.refcount.fetch_add(1, Ordering::Relaxed);
StrongRuleNode::from_ptr(self.p) unsafe { StrongRuleNode::from_ptr(self.p) }
} }
fn from_ptr(p: ptr::NonNull<RuleNode>) -> Self { fn from_ptr(p: ptr::NonNull<RuleNode>) -> Self {