PrivateAllocatorCapabilityState identity #259
-
Not sure if this is a bug or a clever piece of C magic ? defines identifier as a uint16_t, but the value assigned to it is a uint32_t The public version of the struct has some padding at the end, so I don't think it would break anything, but it looks odd ? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The value will be truncated on assignment. Line 388 checks that it is a small enough value to be stored in the owner field of the chunk header, which is narrower than a 16-bit value and so, implicitly, that truncating to 16 bits will be sufficient. We store it as a 32-bit value so that we can do the overflow checks easily: if it overflows a 16-bit value by one, it’s still a valid 32-bit value and so the comparison on line 388 is safe and in range. We should probably add:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the explanation. |
Beta Was this translation helpful? Give feedback.
The value will be truncated on assignment. Line 388 checks that it is a small enough value to be stored in the owner field of the chunk header, which is narrower than a 16-bit value and so, implicitly, that truncating to 16 bits will be sufficient. We store it as a 32-bit value so that we can do the overflow checks easily: if it overflows a 16-bit value by one, it’s still a valid 32-bit value and so the comparison on line 388 is safe and in range.
We should probably add: