Skip to content
This repository was archived by the owner on Mar 7, 2021. It is now read-only.

Commit 9036b65

Browse files
committed
Fixed build for stable GlobalAllocator
1 parent a67c70c commit 9036b65

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/allocator.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
use alloc::heap::{AllocErr, GlobalAlloc, Layout, Opaque};
1+
use core::alloc::{AllocErr, GlobalAlloc, Layout};
22

33
use bindings;
44
use c_types;
55

66
pub struct KernelAllocator;
77

88
unsafe impl GlobalAlloc for KernelAllocator {
9-
unsafe fn alloc(&self, layout: Layout) -> *mut Opaque {
9+
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
1010
// krealloc is used instead of kmalloc because kmalloc is an inline function and can't be
1111
// bound to as a result
1212
return bindings::krealloc(
1313
0 as *const c_types::c_void,
1414
layout.size(),
1515
bindings::GFP_KERNEL,
16-
) as *mut Opaque;
16+
) as *mut u8;
1717
}
1818

19-
unsafe fn dealloc(&self, ptr: *mut Opaque, _layout: Layout) {
19+
unsafe fn dealloc(&self, ptr: *mut u8, _layout: Layout) {
2020
bindings::kfree(ptr as *const c_types::c_void);
2121
}
2222
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![no_std]
2-
#![feature(alloc, global_allocator, allocator_api, const_fn, lang_items, panic_implementation)]
2+
#![feature(alloc, allocator_api, const_fn, lang_items, panic_implementation)]
33

44
#[macro_use]
55
extern crate alloc;

0 commit comments

Comments
 (0)