diff --git a/src/utilities.cc b/src/utilities.cc index 6b9a69e63..b69297313 100644 --- a/src/utilities.cc +++ b/src/utilities.cc @@ -60,7 +60,7 @@ using std::string; _START_GOOGLE_NAMESPACE_ -static const char* g_program_invocation_short_name = NULL; +static std::string g_program_invocation_short_name; _END_GOOGLE_NAMESPACE_ @@ -168,8 +168,8 @@ _START_GOOGLE_NAMESPACE_ namespace glog_internal_namespace_ { const char* ProgramInvocationShortName() { - if (g_program_invocation_short_name != NULL) { - return g_program_invocation_short_name; + if (!g_program_invocation_short_name.empty()) { + return g_program_invocation_short_name.c_str(); } else { // TODO(hamaji): Use /proc/self/cmdline and so? return "UNKNOWN"; @@ -177,7 +177,7 @@ const char* ProgramInvocationShortName() { } bool IsGoogleLoggingInitialized() { - return g_program_invocation_short_name != NULL; + return !g_program_invocation_short_name.empty(); } #ifdef OS_WINDOWS @@ -350,7 +350,7 @@ void InitGoogleLoggingUtilities(const char* argv0) { void ShutdownGoogleLoggingUtilities() { CHECK(IsGoogleLoggingInitialized()) << "You called ShutdownGoogleLogging() without calling InitGoogleLogging() first!"; - g_program_invocation_short_name = NULL; + g_program_invocation_short_name.clear(); #ifdef HAVE_SYSLOG_H closelog(); #endif