This is an automated email from the ASF dual-hosted git repository.

GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit ba1023dc83d4d3ce3b458baea37aa280c03d3ed5
Author: huojianchao <[email protected]>
AuthorDate: Mon Aug 4 14:47:14 2025 +0800

    mm/mempool: add mempool_multiple_member() api
    
    Add mempool_multiple_member() to check whether an address lies in one
    of the pools managed by a multiple mempool.  The heap delay list will
    hold mempool blocks as well as heap chunks, and its debug checks need
    to tell the two apart before inspecting the heap node header.
    
    Signed-off-by: huojianchao <[email protected]>
---
 include/nuttx/mm/mempool.h    | 18 ++++++++++++++++++
 mm/mempool/mempool_multiple.c | 21 +++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/nuttx/mm/mempool.h b/include/nuttx/mm/mempool.h
index fbf3ba6aabb..fb0215dd850 100644
--- a/include/nuttx/mm/mempool.h
+++ b/include/nuttx/mm/mempool.h
@@ -574,6 +574,24 @@ struct mallinfo_task
 mempool_multiple_info_task(FAR struct mempool_multiple_s *mpool,
                            FAR const struct malltask *task);
 
+/****************************************************************************
+ * Name: mempool_multiple_member
+ *
+ * Description:
+ *   Check if an address lies in the mempool.
+ *
+ * Input Parameters:
+ *   mpool - The handle of the multiple memory pool to be used.
+ *   blk   - The pointer of memory block.
+ *
+ * Returned Value:
+ *   true if the address is a member of the mempool.  false if not.
+ *
+ ****************************************************************************/
+
+bool mempool_multiple_member(FAR struct mempool_multiple_s *mpool,
+                             FAR void *blk);
+
 #if defined(__cplusplus)
 }
 #endif
diff --git a/mm/mempool/mempool_multiple.c b/mm/mempool/mempool_multiple.c
index b4bbfb7bd15..58c6caf759d 100644
--- a/mm/mempool/mempool_multiple.c
+++ b/mm/mempool/mempool_multiple.c
@@ -901,3 +901,24 @@ void mempool_multiple_deinit(FAR struct mempool_multiple_s 
*mpool)
   nxrmutex_destroy(&mpool->lock);
   mpool->free(mpool->arg, mpool);
 }
+
+/****************************************************************************
+ * Name: mempool_multiple_member
+ *
+ * Description:
+ *   Check if an address lies in the mempool.
+ *
+ * Input Parameters:
+ *   mpool - The handle of the multiple memory pool to be used.
+ *   blk   - The pointer of memory block.
+ *
+ * Returned Value:
+ *   true if the address is a member of the mempool.  false if not.
+ *
+ ****************************************************************************/
+
+bool mempool_multiple_member(FAR struct mempool_multiple_s *mpool,
+                             FAR void *blk)
+{
+  return mempool_multiple_get_dict(mpool, blk) != NULL;
+}

Reply via email to