Skip to content

Commit

Permalink
Move lookahead buffer offset at the first free block if such block do…
Browse files Browse the repository at this point in the history
…esn't exist move it for whole lookahead size.
  • Loading branch information
ondrapCZE authored and geky committed Sep 21, 2023
1 parent b637379 commit d85a0fe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d85a0fe

Please sign in to comment.