Skip to content

Commit

Permalink
<?> Move lookahead buffer offset at the first free block if such bloc…
Browse files Browse the repository at this point in the history
…k doesn't exist move it for whole lookahead size.

COMMIT_INFO:{
      "branch": "New-function-lfs_find_free_blocks",
        "task": "<?>",
         "url": "<?>"
}
  • Loading branch information
ondrapCZE committed Aug 29, 2023
1 parent 444d243 commit 5443bd2
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->cfg->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 5443bd2

Please sign in to comment.