On Tue, 23 Dec 2025 07:40:16 GMT, Shawn M Emery <[email protected]> wrote:
>> This is the `MemorySegment allocate(SegmentAllocator allocator)` method in >> the generated `passwd.java`. If I understand correctly, the 2nd argument to >> `getpwuid_r` should be the pointer to a single `passwd` struct and the 3rd >> is to a big enough memory to hold contents of extra pointers inside `passwd`. > > Yes, ideally the 3rd argument would be the size of platform's maximum pwd > struct buffer size, which at least can found found on linux and macos with > _SC_GETPW_R_SIZE_MAX using sysconf. The sysconf FFM would not be a > must-have, but would be a nice addition (along with errno) as part of the > core libraries in the future. Oh no, `_SC_GETPW_R_SIZE_MAX` itself is 70 on Linux and 71 on macOS. One cross-platform solution I can think of is to set the buffer size to 1K and if not enough double it until enough. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/28931#discussion_r2644696880
