anchao opened a new pull request, #21037: URL: https://github.com/apache/nuttx/pull/21037
## Summary
Optimize `mempool_multiple_realloc()` by returning the original block when
the requested size still fits in the current multiple mempool block.
The previous implementation always allocated a new block, copied data, and
freed the old block even when the new size stayed within the same pool size
class. This change adds an in-place fast path for normal mempool blocks.
## Details
The fast path is used only when:
- the requested size is non-zero
- the requested size is no larger than the current pool block size
- the old pointer is the base address of the mempool block
The base-address check keeps existing behavior for interior pointers such as
`mempool_multiple_memalign()` results, where the available tail space may be
smaller than the full pool block.
## Benefits
- Avoids unnecessary allocation
- Avoids unnecessary data copy
- Avoids unnecessary free/requeue work
- Reduces lock and allocator churn for same-size-class reallocations
## Testing
sim/nsh
--
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]
