diff --git a/easy-fs/src/block_cache.rs b/easy-fs/src/block_cache.rs index 4b90294a..1b3b9697 100644 --- a/easy-fs/src/block_cache.rs +++ b/easy-fs/src/block_cache.rs @@ -1,11 +1,13 @@ use super::{BlockDevice, BLOCK_SZ}; use alloc::collections::VecDeque; use alloc::sync::Arc; +use alloc::vec; +use alloc::vec::Vec; use lazy_static::*; use spin::Mutex; pub struct BlockCache { - cache: [u8; BLOCK_SZ], + cache: Vec, block_id: usize, block_device: Arc, modified: bool, @@ -14,7 +16,8 @@ pub struct BlockCache { impl BlockCache { /// Load a new BlockCache from disk. pub fn new(block_id: usize, block_device: Arc) -> Self { - let mut cache = [0u8; BLOCK_SZ]; + // for alignment and move effciency + let mut cache = vec![0u8; BLOCK_SZ]; block_device.read_block(block_id, &mut cache); Self { cache,