casaroli commented on code in PR #21037:
URL: https://github.com/apache/nuttx/pull/21037#discussion_r4391677647


##########
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:
   This also keeps the block when the size shrinks to a smaller pool: 
realloc(p, 16) on a 512-byte block now keeps the 512-byte block, where before 
the data moved to the 16-byte pool.
   
   Fix: reuse the block only when `mempool_multiple_find(mpool, size) == 
dict->pool`.
   



-- 
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]

Reply via email to