This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 0b7dc9bcb69e9f259d01824f4fcface640e29b26 Author: Bowen Wang <[email protected]> AuthorDate: Thu Jul 31 23:20:01 2025 +0800 !mm/mempool: add name in mempool to store the mempool name Store the name in struct mempool_s instead of passing it to mempool_init(), so a pool defined statically can carry its own name and be initialized later without the caller supplying one. BREAKING CHANGE: mempool_init() drops its name argument. Quick fix: set pool->name before the call and call mempool_init(pool). Signed-off-by: Bowen Wang <[email protected]> --- include/nuttx/mm/mempool.h | 4 ++-- mm/mempool/mempool.c | 5 ++--- mm/mempool/mempool_multiple.c | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/nuttx/mm/mempool.h b/include/nuttx/mm/mempool.h index 60cb8129a1d..d9e3ee47776 100644 --- a/include/nuttx/mm/mempool.h +++ b/include/nuttx/mm/mempool.h @@ -100,6 +100,7 @@ struct mempool_s size_t maxalloc; /* The maximum allowed alloc number, 0 means not limit */ bool wait; /* The flag of need to wait when mempool is empty */ FAR void *priv; /* This pointer is used to store the user's private data */ + FAR const char *name; /* The name of the mempool */ mempool_alloc_t alloc; /* The alloc function for mempool */ mempool_free_t free; /* The free function for mempool */ mempool_check_t check; /* The check function for mempool */ @@ -164,14 +165,13 @@ extern "C" * * Input Parameters: * pool - Address of the memory pool to be used. - * name - The name of memory pool. * * Returned Value: * Zero on success; A negated errno value is returned on any failure. * ****************************************************************************/ -int mempool_init(FAR struct mempool_s *pool, FAR const char *name); +int mempool_init(FAR struct mempool_s *pool); /**************************************************************************** * Name: mempool_allocate diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index 096a49ddbe6..28deecfbc71 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -258,14 +258,13 @@ mempool_memdump_free_callback(FAR struct mempool_s *pool, * * Input Parameters: * pool - Address of the memory pool to be used. - * name - The name of memory pool. * * Returned Value: * Zero on success; A negated errno value is returned on any failure. * ****************************************************************************/ -int mempool_init(FAR struct mempool_s *pool, FAR const char *name) +int mempool_init(FAR struct mempool_s *pool) { size_t blocksize = MEMPOOL_REALBLOCKSIZE(pool); @@ -333,7 +332,7 @@ int mempool_init(FAR struct mempool_s *pool, FAR const char *name) } #if defined(CONFIG_FS_PROCFS) && !defined(CONFIG_FS_PROCFS_EXCLUDE_MEMPOOL) - mempool_procfs_register(&pool->procfs, name); + mempool_procfs_register(&pool->procfs, pool->name); # ifdef CONFIG_MM_BACKTRACE_DEFAULT pool->procfs.backtrace = true; # elif CONFIG_MM_BACKTRACE > 0 diff --git a/mm/mempool/mempool_multiple.c b/mm/mempool/mempool_multiple.c index ead52892331..b826d55a307 100644 --- a/mm/mempool/mempool_multiple.c +++ b/mm/mempool/mempool_multiple.c @@ -460,6 +460,7 @@ mempool_multiple_init(FAR const char *name, pools[i].initialsize = 0; pools[i].interruptsize = 0; pools[i].priv = mpool; + pools[i].name = name; pools[i].alloc = mempool_multiple_alloc_callback; pools[i].free = mempool_multiple_free_callback; pools[i].check = mempool_multiple_check; @@ -468,7 +469,7 @@ mempool_multiple_init(FAR const char *name, #else pools[i].wait = false; #endif - ret = mempool_init(pools + i, name); + ret = mempool_init(pools + i); if (ret < 0) { goto err_with_pools;
