nuttx/fs/littlefs/lfs_util.patch
chenrun1 3f47fd767a fs/xxfs:Replace kmm with fs heap
Summary:
  1.Add configuration to allocate memory from the specified section
  2.Replace all memory operations (kmm_) in the vfs with
    fs_heap_. When FS_HEAPSIZE > 0, memory is requested for the file system by specifying a configured heap location. By default (i.e. FS_HEAPSIZE=0) fs_heap_ is equivalent to kmm_

Signed-off-by: chenrun1 <chenrun1@xiaomi.com>
2024-10-10 15:30:41 +02:00

30 lines
758 B
Diff

--- ./littlefs/littlefs/lfs_util.h 2022-11-11 03:32:30.000000000 +1100
+++ ./littlefs/littlefs/lfs_util.h 2023-04-21 12:25:27.987084276 +1000
@@ -28,6 +28,8 @@
#ifndef LFS_NO_MALLOC
#include <stdlib.h>
+#include <nuttx/mm/mm.h>
+#include "fs_heap.h"
#endif
#ifndef LFS_NO_ASSERT
#include <assert.h>
@@ -218,7 +219,7 @@
// Note, memory must be 64-bit aligned
static inline void *lfs_malloc(size_t size) {
#ifndef LFS_NO_MALLOC
- return malloc(size);
+ return fs_heap_malloc(size);
#else
(void)size;
return NULL;
@@ -228,7 +229,7 @@
// Deallocate memory, only used if buffers are not provided to littlefs
static inline void lfs_free(void *p) {
#ifndef LFS_NO_MALLOC
- free(p);
+ fs_heap_free(p);
#else
(void)p;
#endif