RFR 8207016 : [win] Avoid redundant native memory allocation in getFinalPath()

Ivan Gerasimov ivan.gerasimov at oracle.com
Wed Jul 11 02:33:50 UTC 2018


Hello!

File src/java.base/windows/native/libjava/WinNTFileSystem_md.c
The function getFinalPath() is wrapper for GetFinalPathNameByHandleW(), 
which is used to resolve the symlinks on Windows.

If the resulting string begins with a prefix "\\?\" or "\\?\UNC", a copy 
without the prefix is created and returned.

Instead of creating the copy, we can override the result with memmove() 
to avoid allocating extra native memory.
The result of getFinalPath() is short living anyway, so a few unused 
bytes at the end of the buffer should not be a problem.

The advantage is a shorter code and minus one point of possible failure.

Would you please help review it?

BUG: https://bugs.openjdk.java.net/browse/JDK-8207016
Webrev: http://cr.openjdk.java.net/~igerasim/8207016/00/webrev/

Thanks in advance!

-- 
With kind regards,
Ivan Gerasimov



More information about the core-libs-dev mailing list