Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "shared_vector"
version = "0.4.4"
version = "0.4.5"
edition = "2021"
authors = ["Nicolas Silva <nical@fastmail.com>"]
repository = "https://github.com/nical/shared_vector"
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ macro_rules! arc_vector {

#[test]
fn vector_macro() {
pub use allocator_api2::alloc::{Allocator, Global};
pub use allocator_api2::alloc::Global;

let v1: Vector<u32> = vector![0, 1, 2, 3, 4, 5];
let v2: Vector<u32> = vector![2; 4];
Expand Down
6 changes: 4 additions & 2 deletions src/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use core::sync::atomic::{
Ordering::{Relaxed, Release},
};

pub use crate::alloc::{AllocError, Allocator, Global};
pub use crate::alloc::{AllocError, Allocator};

pub type BufferSize = u32;

Expand Down Expand Up @@ -224,7 +224,7 @@ pub unsafe fn extend_within_capacity<T, I: Iterator<Item = T>>(data: *mut T, vec
if let Some(item) = iter.next() {
ptr::write(ptr, item);
ptr = ptr.add(1);
count += 1;
count += 1;
} else {
finished = true;
break;
Expand Down Expand Up @@ -298,6 +298,8 @@ pub unsafe fn header_from_data_ptr<H, T>(data_ptr: NonNull<T>) -> NonNull<H> {

#[test]
fn buffer_layout_alignemnt() {
pub use crate::alloc::Global;

type B = Box<u32>;
let layout = buffer_layout::<Header<DefaultRefCount, Global>, B>(2).unwrap();
assert_eq!(layout.align(), mem::size_of::<B>());
Expand Down
6 changes: 4 additions & 2 deletions src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<T, R: RefCount, A: Allocator> RefCountedVector<T, R, A> {
// SAFETY: call this only if the vector is unique.
pub(crate) unsafe fn vec_header_mut(&mut self) -> &mut raw::VecHeader {
&mut self.inner.as_mut().vec
}
}

pub(crate) fn vec_header(&self) -> &raw::VecHeader {
unsafe { &self.inner.as_ref().vec }
Expand Down Expand Up @@ -634,7 +634,7 @@ impl<T, R: RefCount, A: Allocator> Drop for RefCountedVector<T, R, A> {
// we only need it for the atomic reference counted version but I don't expect
// this to make a measurable difference.
core::sync::atomic::fence(Ordering::Acquire);

raw::drop_items(self.data_ptr(), header.len);
raw::dealloc::<T, R, A>(self.inner.header, header.cap);
}
Expand All @@ -645,6 +645,8 @@ impl<T, R: RefCount, A: Allocator> Drop for RefCountedVector<T, R, A> {

unsafe impl<T: Sync, A: Allocator + Send> Send for AtomicSharedVector<T, A> {}

unsafe impl<T: Send + Sync, A: Allocator + Sync> Sync for AtomicSharedVector<T, A> {}

impl<T, R: RefCount, A: Allocator> Clone for RefCountedVector<T, R, A> {
fn clone(&self) -> Self {
self.new_ref()
Expand Down
Loading