On Thu, 20 Nov 2025 14:57:34 GMT, Jorn Vernee <[email protected]> wrote:

>> Harald Eilertsen has updated the pull request incrementally with one 
>> additional commit since the last revision:
>> 
>>   Replace conditional with Math.max intrinsic
>>   
>>   Co-authored-by: ExE Boss <[email protected]>
>
> src/java.base/share/classes/jdk/internal/foreign/SegmentFactories.java line 
> 215:
> 
>> 213:             result = Utils.alignUp(allocationBase, byteAlignment);
>> 214:         } else {
>> 215:             allocationSize = Math.max(alignedSize, byteAlignment);
> 
> This looks correct but it really needs a comment.

Suggestion:

            // always allocate at least 'byteAlignment' bytes, so that malloc 
is guaranteed to 
            // return a pointer aligned to that alignment, for cases where 
byteAlignment > alignedSize
            allocationSize = Math.max(alignedSize, byteAlignment);

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28235#discussion_r2546417290

Reply via email to