mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Auto merge of #23843 - emilio:insta-boom, r=SimonSapin
Don't insta-free in UniqueArc::assume_init. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23843) <!-- Reviewable:end -->
This commit is contained in:
commit
adefd2cdfc
1 changed files with 7 additions and 1 deletions
|
@ -125,6 +125,12 @@ impl<T> UniqueArc<T> {
|
|||
.unwrap_or_else(|| alloc::handle_alloc_error(layout))
|
||||
.cast::<ArcInner<mem::MaybeUninit<T>>>();
|
||||
ptr::write(&mut p.as_mut().count, atomic::AtomicUsize::new(1));
|
||||
|
||||
#[cfg(feature = "gecko_refcount_logging")]
|
||||
{
|
||||
NS_LogCtor(p.as_ptr() as *mut _, b"ServoArc\0".as_ptr() as *const _, 8)
|
||||
}
|
||||
|
||||
UniqueArc(Arc {
|
||||
p,
|
||||
phantom: PhantomData,
|
||||
|
@ -144,7 +150,7 @@ impl<T> UniqueArc<mem::MaybeUninit<T>> {
|
|||
#[inline]
|
||||
pub unsafe fn assume_init(this: Self) -> UniqueArc<T> {
|
||||
UniqueArc(Arc {
|
||||
p: this.0.p.cast(),
|
||||
p: mem::ManuallyDrop::new(this).0.p.cast(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue