[compiler-rt] [scudo] Add free_sized and free_aligned_sized (PR #186881)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 23 10:50:13 PDT 2026
================
@@ -442,8 +444,66 @@ class Allocator {
SizeOrUnusedBytes, FillContents);
}
- NOINLINE void deallocate(void *Ptr, Chunk::Origin Origin, uptr DeleteSize = 0,
- UNUSED uptr Alignment = MinAlignment) {
+ ALWAYS_INLINE void deallocate(void *Ptr, Chunk::Origin Origin) {
+ deallocate(Ptr, Origin, /*DeleteSize=*/0, /*DeleteAlignment=*/0);
+ }
+
+ ALWAYS_INLINE void deallocateSized(void *Ptr, Chunk::Origin Origin,
+ uptr DeleteSize) {
+ deallocate(Ptr, Origin | Chunk::Origin::Size, DeleteSize,
+ /*DeleteAlignment=*/0);
----------------
ChiaHungDuan wrote:
I'm wondering if a minor refactor helps the readability here given that the `DeleteSize` and `DeleteAlignment` are only used for checks. I'm thinking something like
```
deallocateSize(...) {
loadHeader();
checkDeleteSizeAndDeleteAlignment()
deallocate();
}
```
We only leave the `DeleteSize` and `DeleteAlignment` in the specific paths. What makes me think this is when I see the default values here. `DeleteSize=0` reminds me that if it should match with `malloc(0)` and `DeleteAlignment=0` makes me wonder if we want a default alignment to be used.
I'm not sure if the refactoring will be complicated. Just a thought sharing
https://github.com/llvm/llvm-project/pull/186881
More information about the llvm-commits
mailing list