Skip to content

Commit 105b2b8

Browse files
Danilo Krummrichfbq
authored andcommitted
rust: alloc: implement kernel Vec type
`Vec` provides a contiguous growable array type (such as `Vec`) with contents allocated with the kernel's allocators (e.g. `Kmalloc`, `Vmalloc` or `KVmalloc`). In contrast to Rust's `Vec` type, the kernel `Vec` type considers the kernel's GFP flags for all appropriate functions, always reports allocation failures through `Result<_, AllocError>` and remains independent from unstable features. Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 37132d8 commit 105b2b8

File tree

3 files changed

+636
-1
lines changed

3 files changed

+636
-1
lines changed

rust/kernel/alloc.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#[cfg(not(any(test, testlib)))]
66
pub mod allocator;
77
pub mod kbox;
8+
pub mod kvec;
89
pub mod vec_ext;
910

1011
#[cfg(any(test, testlib))]
@@ -18,6 +19,11 @@ pub use self::kbox::KBox;
1819
pub use self::kbox::KVBox;
1920
pub use self::kbox::VBox;
2021

22+
pub use self::kvec::KVVec;
23+
pub use self::kvec::KVec;
24+
pub use self::kvec::VVec;
25+
pub use self::kvec::Vec;
26+
2127
/// Indicates an allocation error.
2228
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
2329
pub struct AllocError;

0 commit comments

Comments
 (0)