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
The following commit(s) were added to refs/heads/master by this push:
new 706b328088c mm/mempool: Fix multiple pool exact size lookup
706b328088c is described below
commit 706b328088c2aba6bd447cb7e3ffac42a321d6e6
Author: chao an <[email protected]>
AuthorDate: Tue Oct 27 17:13:53 2026 +0800
mm/mempool: Fix multiple pool exact size lookup
Use lower-bound lookup for non-linear pool size classes so exact-size
requests are served by the matching pool instead of the next larger one.
Signed-off-by: chao an <[email protected]>
---
mm/mempool/mempool_multiple.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/mempool/mempool_multiple.c b/mm/mempool/mempool_multiple.c
index 7f31b7ef368..a53faa06ecd 100644
--- a/mm/mempool/mempool_multiple.c
+++ b/mm/mempool/mempool_multiple.c
@@ -127,7 +127,7 @@ mempool_multiple_find(FAR struct mempool_multiple_s *mpool,
size_t size)
while (left < right)
{
mid = (left + right) >> 1;
- if (mpool->pools[mid].blocksize > size)
+ if (mpool->pools[mid].blocksize >= size)
{
right = mid;
}
@@ -718,6 +718,7 @@ FAR void *mempool_multiple_memalign(FAR struct
mempool_multiple_s *mpool,
do
{
FAR char *blk = mempool_allocate(pool);
+
if (blk != NULL)
{
return (FAR void *)ALIGN_UP((uintptr_t)blk, alignment);
@@ -737,6 +738,7 @@ void mempool_multiple_foreach(FAR struct mempool_multiple_s
*mpool,
FAR void *arg)
{
size_t i;
+
for (i = 0; i < mpool->npools; i++)
{
handle(mpool->pools + i, arg);