From e33498376747d2ab7a313ebc5e96cd9e3a6c13db Mon Sep 17 00:00:00 2001 From: yog Date: Wed, 17 Nov 2021 15:34:25 +0100 Subject: [PATCH] don't use lfs_file_open() when LFS_NO_MALLOC is set --- lfs.c | 2 ++ lfs.h | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lfs.c b/lfs.c index d976389..cf566f8 100644 --- a/lfs.c +++ b/lfs.c @@ -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) { @@ -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, diff --git a/lfs.h b/lfs.h index ad49162..063c5eb 100644 --- a/lfs.h +++ b/lfs.h @@ -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 @@ -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