Skip to content

Commit a1e2445

Browse files
committed
fix nightly >= 2020-04-02. release 0.3.9
1 parent c8d6c75 commit a1e2445

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

.github/workflows/rust.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
- nightly-2020-03-04
2020
- nightly-2020-03-10
2121
- nightly-2020-03-11
22+
- nightly-2020-04-01
23+
- nightly-2020-04-02
2224

2325
steps:
2426
- uses: actions/checkout@v2

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ documentation = "https://docs.rs/buddy_system_allocator"
55
homepage = "https://github.com/rcore-os/buddy_system_allocator"
66
repository = "https://github.com/rcore-os/buddy_system_allocator"
77
keywords = ["allocator", "no_std", "heap"]
8-
version = "0.3.8"
8+
version = "0.3.9"
99
authors = ["Jiajie Chen <noc@jiegec.ac.cn>"]
1010
edition = "2018"
1111
license = "MIT"

src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ use alloc::alloc::Alloc;
1717
#[rustversion::since(2020-02-02)]
1818
use alloc::alloc::AllocRef;
1919
use alloc::alloc::{AllocErr, Layout};
20+
#[rustversion::since(2020-04-02)]
21+
use alloc::alloc::{AllocInit, MemoryBlock};
2022
use core::alloc::GlobalAlloc;
2123
use core::cmp::{max, min};
2224
use core::fmt;
@@ -223,11 +225,25 @@ unsafe impl AllocRef for Heap {
223225
self.alloc(layout).map(|p| (p, layout.size()))
224226
}
225227

226-
#[rustversion::since(2020-03-10)]
228+
#[rustversion::all(since(2020-03-10), before(2020-04-02))]
227229
fn alloc(&mut self, layout: Layout) -> Result<(NonNull<u8>, usize), AllocErr> {
228230
self.alloc(layout).map(|p| (p, layout.size()))
229231
}
230232

233+
#[rustversion::since(2020-04-02)]
234+
fn alloc(&mut self, layout: Layout, init: AllocInit) -> Result<MemoryBlock, AllocErr> {
235+
self.alloc(layout).map(|p| {
236+
let block = MemoryBlock {
237+
ptr: p,
238+
size: layout.size(),
239+
};
240+
unsafe {
241+
init.init(block);
242+
}
243+
block
244+
})
245+
}
246+
231247
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout) {
232248
self.dealloc(ptr, layout)
233249
}

0 commit comments

Comments
 (0)