From 22bcb88687fe864cea0503ba68803b40cf0539b9 Mon Sep 17 00:00:00 2001 From: xuxingliang Date: Tue, 15 Oct 2024 20:10:06 +0800 Subject: [PATCH] fs_heap: add memalign interface So the share memory can use it to malloc aligned memory. Signed-off-by: xuxingliang --- fs/fs_heap.c | 5 +++++ fs/fs_heap.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/fs/fs_heap.c b/fs/fs_heap.c index bb8a9ef966..faacb034d6 100644 --- a/fs/fs_heap.c +++ b/fs/fs_heap.c @@ -68,6 +68,11 @@ FAR void *fs_heap_realloc(FAR void *oldmem, size_t size) return mm_realloc(g_fs_heap, oldmem, size); } +FAR void *fs_heap_memalign(size_t alignment, size_t size) +{ + return mm_memalign(g_fs_heap, alignment, size); +} + void fs_heap_free(FAR void *mem) { mm_free(g_fs_heap, mem); diff --git a/fs/fs_heap.h b/fs/fs_heap.h index fa22370eee..5dc48dad8e 100644 --- a/fs/fs_heap.h +++ b/fs/fs_heap.h @@ -43,6 +43,7 @@ FAR void *fs_heap_zalloc(size_t size) malloc_like1(1); FAR void *fs_heap_malloc(size_t size) malloc_like1(1); size_t fs_heap_malloc_size(FAR void *mem); FAR void *fs_heap_realloc(FAR void *oldmem, size_t size) realloc_like(2); +FAR void *fs_heap_memalign(size_t alignment, size_t size) malloc_like1(3); void fs_heap_free(FAR void *mem); FAR char *fs_heap_strdup(FAR const char *s) malloc_like; FAR char *fs_heap_strndup(FAR const char *s, size_t size) malloc_like; @@ -54,6 +55,7 @@ int fs_heap_asprintf(FAR char **strp, FAR const char *fmt, ...) # define fs_heap_malloc kmm_malloc # define fs_heap_malloc_size kmm_malloc_size # define fs_heap_realloc kmm_realloc +# define fs_heap_memalign kmm_memalign # define fs_heap_free kmm_free # define fs_heap_strdup strdup # define fs_heap_strndup strndup