Skip to content

Commit 922e72a

Browse files
authored
feat: release 0.1.2 (#7)
* feat: add Default impl, fix clippy warnings * feat: bump version to 0.1.2
1 parent a472413 commit 922e72a

File tree

7 files changed

+27
-2
lines changed

7 files changed

+27
-2
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "allocator"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
edition = "2021"
55
authors = ["Yuekai Jia <equation618@gmail.com>"]
66
description = "Various allocator algorithms in a unified interface"

benches/collections.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const POOL_SIZE: usize = 1024 * 1024 * 128;
1717

1818
fn vec_push(n: usize, alloc: &(impl Allocator + Clone)) {
1919
let mut v: Vec<u32, _> = Vec::new_in(alloc.clone());
20+
#[allow(clippy::same_item_push)]
2021
for _ in 0..n {
2122
v.push(0xdead_beef);
2223
}

src/bitmap.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ impl<const PAGE_SIZE: usize> BitmapPageAllocator<PAGE_SIZE> {
5050
}
5151
}
5252

53+
impl<const PAGE_SIZE: usize> Default for BitmapPageAllocator<PAGE_SIZE> {
54+
fn default() -> Self {
55+
Self::new()
56+
}
57+
}
58+
5359
impl<const PAGE_SIZE: usize> BaseAllocator for BitmapPageAllocator<PAGE_SIZE> {
5460
fn init(&mut self, start: usize, size: usize) {
5561
assert!(PAGE_SIZE.is_power_of_two());

src/buddy.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ impl BuddyByteAllocator {
2424
}
2525
}
2626

27+
impl Default for BuddyByteAllocator {
28+
fn default() -> Self {
29+
Self::new()
30+
}
31+
}
32+
2733
impl BaseAllocator for BuddyByteAllocator {
2834
fn init(&mut self, start: usize, size: usize) {
2935
unsafe { self.inner.init(start, size) };

src/slab.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ impl SlabByteAllocator {
2929
}
3030
}
3131

32+
impl Default for SlabByteAllocator {
33+
fn default() -> Self {
34+
Self::new()
35+
}
36+
}
37+
3238
impl BaseAllocator for SlabByteAllocator {
3339
fn init(&mut self, start: usize, size: usize) {
3440
self.inner = unsafe { Some(Heap::new(start, size)) };

src/tlsf.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ impl TlsfByteAllocator {
2828
}
2929
}
3030

31+
impl Default for TlsfByteAllocator {
32+
fn default() -> Self {
33+
Self::new()
34+
}
35+
}
36+
3137
impl BaseAllocator for TlsfByteAllocator {
3238
fn init(&mut self, start: usize, size: usize) {
3339
unsafe {

tests/allocator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn test_alignment(n: usize, alloc: &(impl Allocator + Clone)) {
6464
let mut rng = rand::thread_rng();
6565
let mut blocks = vec![];
6666
for _ in 0..n {
67-
if rng.gen_ratio(2, 3) || blocks.len() == 0 {
67+
if rng.gen_ratio(2, 3) || blocks.is_empty() {
6868
// insert a block
6969
let size =
7070
((1 << rng.gen_range(0..16)) as f32 * rng.gen_range(1.0..2.0)).round() as usize;

0 commit comments

Comments
 (0)