Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lfs.c
diff options
context:
space:
mode:
authorondrap <pilat.ondrej@seznam.cz>2023-08-29 13:50:16 +0300
committerChristopher Haster <geky@geky.net>2023-09-21 20:21:25 +0300
commitd85a0fe2e2f1a2c48d80b05a29c3c60a28c7e3b0 (patch)
treedc0d54f4d6330abf1dfbff9bbd3cfdeb1d2efefb /lfs.c
parentb6373792106f04d8de6b959be61062b89d5b793a (diff)
Move lookahead buffer offset at the first free block if such block doesn't exist move it for whole lookahead size.
Diffstat (limited to 'lfs.c')
-rw-r--r--lfs.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lfs.c b/lfs.c
index 250e734..3664e80 100644
--- a/lfs.c
+++ b/lfs.c
@@ -662,7 +662,9 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block) {
}
int lfs_find_free_blocks(lfs_t *lfs){
- lfs->free.off = (lfs->free.off + lfs->free.size)
+ // Move free offset at the first unused block (lfs->free.i)
+ // lfs->free.i is equal lfs->free.size when all blocks are used
+ lfs->free.off = (lfs->free.off + lfs->free.i)
% lfs->block_count;
lfs->free.size = lfs_min(8*lfs->cfg->lookahead_size, lfs->free.ack);
lfs->free.i = 0;