Reputation: 3950
The traditional way to call the Unix realpath()
function has been realpath(pathname, buf)
where buf
is a user-supplied buffer with room for PATH_MAX
bytes. This is problematic since PATH_MAX
is unnecessarily big for most filenames and yet can be smaller than the actual OS pathname length limit.
The ability to pass a NULL
pointer in place of buf
was later added. In this case realpath()
will dynamically allocate a buffer of the right size using malloc()
. This makes the function easy to use safely. Since NULL
support was a later addition, it was not universally implemented and hence portable programs could not rely on it.
POSIX Issue 7, 2018 edition now guarantees NULL
support. Endorsement by POSIX would seem to imply that the portability concerns have all but vanished. Are there any Unix systems in active use (e.g. from the last decade) where realpath()
does not support giving a NULL
buffer?
Upvotes: 4
Views: 451
Reputation: 1282
According to the Gnulib documentation, the Gnulib developers last saw this issue on
Upvotes: 1
Reputation: 3950
realpath(path, NULL)
works on recent releases of at least the following systems:
Upvotes: 1