RFR: JDK-8266503: [UL] Make Decorations safely copy-able and reduce their size [v2]

Xin Liu xliu at openjdk.java.net
Thu May 6 18:46:56 UTC 2021


On Thu, 6 May 2021 18:30:16 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

>> src/hotspot/share/logging/logDecorations.cpp line 39:
>> 
>>> 37:     if (os::get_host_name(buffer, sizeof(buffer))) {
>>> 38:       // Use raw malloc here
>>> 39:       return ::strdup(buffer);
>> 
>> I don't think `strdup` is necessary. If you decide to use static variable, you can use `static char buffer[1024]` in the function.
>
> Hi Xin, I think you review an old version, I reverted that coding.
> 
> But the point about using a pointer and resolving hostname lazily on first access is to prevent paying anything if logging is off or logging is on but the hostname decorator is not used. For a static char array you always have to pay.

Sorry. forget it.   I commented yesterday and just sent out. 
I see you revert host_name(). The reason to use lazy initialization is fair enough.

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

PR: https://git.openjdk.java.net/jdk/pull/3874


More information about the hotspot-runtime-dev mailing list