Skip to content

Commit

Permalink
don't use lfs_file_open() when LFS_NO_MALLOC is set
Browse files Browse the repository at this point in the history
  • Loading branch information
nnayo authored and geky committed Feb 19, 2022
1 parent ead5080 commit e334983
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5082,6 +5082,7 @@ int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type) {
}
#endif

#ifndef LFS_NO_MALLOC
int lfs_file_open(lfs_t *lfs, lfs_file_t *file, const char *path, int flags) {
int err = LFS_LOCK(lfs->cfg);
if (err) {
Expand All @@ -5097,6 +5098,7 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file, const char *path, int flags) {
LFS_UNLOCK(lfs->cfg);
return err;
}
#endif

int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file,
const char *path, int flags,
Expand Down
5 changes: 5 additions & 0 deletions lfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type);

/// File operations ///

#ifndef LFS_NO_MALLOC
// Open a file
//
// The mode that the file is opened in is determined by the flags, which
Expand All @@ -522,6 +523,10 @@ int lfs_removeattr(lfs_t *lfs, const char *path, uint8_t type);
int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
const char *path, int flags);

// if LFS_NO_MALLOC is defined, lfs_file_open() will fail with LFS_ERR_NOMEM
// thus use lfs_file_opencfg() with config.buffer set.
#endif

// Open a file with extra configuration
//
// The mode that the file is opened in is determined by the flags, which
Expand Down

0 comments on commit e334983

Please sign in to comment.