From 416560705e2b30b617f570cf594eaf2b337ca692 Mon Sep 17 00:00:00 2001 From: Cass Fridkin Date: Tue, 18 Jun 2024 21:06:36 -0400 Subject: [PATCH] Try a different strategy for const null pointers --- src/sync.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sync.rs b/src/sync.rs index 99f67c6..351e8c0 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -704,7 +704,7 @@ impl Default for LockFreeFrozenVec { /// any heap allocations until the first time data is pushed to it. fn default() -> Self { Self { - data: [const { Self::null() }; NUM_BUFFERS], + data: Self::null(), len: AtomicUsize::new(0), locked: AtomicBool::new(false), } @@ -712,8 +712,8 @@ impl Default for LockFreeFrozenVec { } impl LockFreeFrozenVec { - const fn null() -> AtomicPtr { - AtomicPtr::new(std::ptr::null_mut()) + const fn null() -> [AtomicPtr; NUM_BUFFERS] { + [const { AtomicPtr::new(std::ptr::null_mut()) }; NUM_BUFFERS] } pub fn new() -> Self { @@ -910,7 +910,7 @@ fn test_non_lockfree_unchecked() { impl Clone for LockFreeFrozenVec { fn clone(&self) -> Self { - let mut coppied_data = [const { Self::null() }; NUM_BUFFERS]; + let mut coppied_data = Self::null(); // for each buffer, copy the data self.for_each_buffer(|buffer_slice, buffer_index| { // allocate a new buffer