anchao commented on code in PR #21037:
URL: https://github.com/apache/nuttx/pull/21037#discussion_r4396596180
##########
mm/mempool/mempool_multiple.c:
##########
@@ -596,6 +597,15 @@ FAR void *mempool_multiple_realloc(FAR struct
mempool_multiple_s *mpool,
return NULL;
}
+ blkbase = (FAR char *)oldblk -
+ (((FAR char *)kasan_clear_tag(oldblk) -
+ ((FAR char *)kasan_clear_tag(dict->addr) +
+ mpool->minpoolsize)) % MEMPOOL_REALBLOCKSIZE(dict->pool));
+ if (size > 0 && size <= dict->pool->blocksize && blkbase == oldblk)
Review Comment:
Done. I changed the fast path to reuse the old block only when
mempool_multiple_find(mpool, size) returns the same pool as the current
block.
This avoids keeping a larger block when realloc shrinks into a smaller size
class, while still avoiding realloc/copy when the requested size stays in
the
same pool.
##########
mm/mempool/mempool_multiple.c:
##########
@@ -596,6 +597,15 @@ FAR void *mempool_multiple_realloc(FAR struct
mempool_multiple_s *mpool,
return NULL;
}
+ blkbase = (FAR char *)oldblk -
+ (((FAR char *)kasan_clear_tag(oldblk) -
+ ((FAR char *)kasan_clear_tag(dict->addr) +
+ mpool->minpoolsize)) % MEMPOOL_REALBLOCKSIZE(dict->pool));
+ if (size > 0 && size <= dict->pool->blocksize && blkbase == oldblk)
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]