Skip to content

Commit 4d0996e

Browse files
committed
mem: Add documentation for newly introduced functions
1 parent daa65f9 commit 4d0996e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: kernel/src/mem/array.rs

+8
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ impl<T: Clone + Copy, const N: usize> Vec<T, N> {
170170
Ok(())
171171
}
172172

173+
/// Reserve a fixed amount of space in the Vec. Does nothing if enough space is present already.
174+
///
175+
/// `total_capacity` - The total space to be reserved.
176+
///
177+
/// Returns `Ok(())` if the space was reserved, otherwise `Err(KernelError::OutOfMemory)`.
173178
pub fn reserve_total_capacity(&mut self, total_capacity: usize) -> Result<(), KernelError> {
174179
// Check if we already have enough space
175180
if self.capacity() >= total_capacity {
@@ -405,6 +410,9 @@ impl<T: Clone + Copy, const N: usize> Vec<T, N> {
405410
self.len == 0
406411
}
407412

413+
/// Get total amount of space in Vec (in- and out-of-line)
414+
///
415+
/// Returns total amount of reserved space in the vec
408416
pub fn capacity(&self) -> usize {
409417
N + self.extra.len()
410418
}

Diff for: kernel/src/mem/queue.rs

+6
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ impl<T: Clone + Copy, const N: usize> Queue<T, N> {
100100
self.len == 0
101101
}
102102

103+
/// Increases total space in the queue preserving queue-integrity, potentially reallocating and copying existing contents
104+
///
105+
/// `new_size` - The total amount of space in the queue afterwards
106+
///
107+
/// Returns `Ok(())` if the queue was successfully enlargened or the requested size was smaller than the current capacity.
108+
/// Returns An error if the queue could not be grown
103109
pub fn grow_capacity(&mut self, new_size: usize) -> Result<(), KernelError> {
104110
if new_size <= self.data.capacity() {
105111
return Ok(());

0 commit comments

Comments
 (0)