소스 검색

Merge pull request #614 from nnayo/fix_no_malloc_2

don't use lfs_file_open() when LFS_NO_MALLOC is set
Christopher Haster 3 년 전
부모
커밋
bfb9bd2483
2개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      lfs.c
  2. 5 0
      lfs.h

+ 2 - 0
lfs.c

@@ -5104,6 +5104,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) {
@@ -5119,6 +5120,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,

+ 5 - 0
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