Skip to content

Commit 1a3d5ee

Browse files
author
Jiajie Chen
committed
Fix alignment and tests
1 parent af073ed commit 1a3d5ee

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

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.4"
8+
version = "0.3.5"
99
authors = ["Jiajie Chen <[email protected]>"]
1010
edition = "2018"
1111
license = "MIT"

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ impl Heap {
7777
/// Add a range of memory [start, end) to the heap
7878
pub unsafe fn add_to_heap(&mut self, mut start: usize, mut end: usize) {
7979
// avoid unaligned access on some platforms
80-
start = (start + size_of::<usize>() - 1) & (!size_of::<usize>());
81-
end = end & (!size_of::<usize>());
80+
start = (start + size_of::<usize>() - 1) & (!size_of::<usize>() + 1);
81+
end = end & (!size_of::<usize>() + 1);
8282
assert!(start <= end);
8383

8484
let mut total = 0;
@@ -273,7 +273,7 @@ use alloc::boxed::Box;
273273
/// Create a locked heap:
274274
/// ```
275275
/// use buddy_system_allocator::*;
276-
/// let heap = LockedHeapWithRescue::new(&|heap: &mut Heap| {});
276+
/// let heap = LockedHeapWithRescue::new(|heap: &mut Heap| {});
277277
/// ```
278278
///
279279
/// Before oom, the allocator will try to call rescue function and try for one more time.

src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ fn test_heap_oom() {
7777
#[test]
7878
fn test_heap_oom_rescue() {
7979
static mut SPACE: [usize; 100] = [0; 100];
80-
let heap = LockedHeapWithRescue::new(&|heap: &mut Heap| unsafe {
80+
let heap = LockedHeapWithRescue::new(|heap: &mut Heap| unsafe {
8181
heap.add_to_heap(SPACE.as_ptr() as usize, SPACE.as_ptr().add(100) as usize);
8282
});
8383

0 commit comments

Comments
 (0)