Skip to content

Commit 2a4b4d7

Browse files
committed
uefi: allocator: improve documentation
1 parent e0c9d78 commit 2a4b4d7

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

uefi/src/allocator.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
// SPDX-License-Identifier: MIT OR Apache-2.0
22

3-
//! This module implements Rust's global allocator interface using UEFI's memory allocation functions.
3+
//! This module exports [`Allocator`].
44
//!
5-
//! If the `global_allocator` feature is enabled, the [`Allocator`] will be used
6-
//! as the global Rust allocator.
5+
//! The allocator can be used as global Rust allocator using the
6+
//! `global_allocator` crate feature. See [`helpers`] for more info.
77
//!
8-
//! This allocator can only be used while boot services are active. If boot
9-
//! services are not active, `alloc` will return a null pointer, and `dealloc`
10-
//! will panic.
8+
//! [`helpers`]: uefi::helpers
119
1210
use crate::boot;
1311
use crate::mem::memory_map::MemoryType;
@@ -42,9 +40,13 @@ fn get_memory_type() -> MemoryType {
4240
}
4341
}
4442

45-
/// Allocator which uses the UEFI pool allocation functions.
43+
/// Allocator using UEFI boot services.
4644
///
47-
/// Only valid for as long as the UEFI boot services are available.
45+
/// This type implements [`GlobalAlloc`] and can be marked with the
46+
/// `#[global_allocator]` attribute to be used as global Rust allocator.
47+
///
48+
/// Note that if boot services are not active (anymore), [`Allocator::alloc`]
49+
/// will return a null pointer and [`Allocator::dealloc`] will panic.
4850
#[derive(Debug)]
4951
pub struct Allocator;
5052

0 commit comments

Comments
 (0)