Skip to content

Commit

Permalink
Ack allocator when freeing a reserved area
Browse files Browse the repository at this point in the history
  • Loading branch information
kaetemi committed Jun 1, 2022
1 parent ff1e46b commit 55fe30e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -3705,7 +3705,15 @@ static int lfs_file_rawtruncate(lfs_t *lfs, lfs_file_t *file, lfs_off_t size) {

if (file->flags & LFS_F_FLAT) {
LFS_ASSERT((file->flags & LFS_F_INLINE) == 0);
if (size == oldsize) {
if (size == 0) {
// just empty the file
file->ctz.head = 0;
file->ctz.size = 0;
file->flags &= ~LFS_F_FLAT;
file->flags |= LFS_F_INLINE | LFS_F_DIRTY;
lfs_alloc_ack(lfs);
return 0;
} else if (size == oldsize) {
// noop
return 0;
} else {
Expand Down Expand Up @@ -3794,6 +3802,7 @@ static int lfs_file_rawreserve(lfs_t *lfs, lfs_file_t *file, lfs_size_t size, in
if (flags & LFS_R_ERRED) {
file->flags |= LFS_F_ERRED;
}
lfs_alloc_ack(lfs);
return LFS_ERR_OK;
}

Expand Down

0 comments on commit 55fe30e

Please sign in to comment.