Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed arg0 lifetime problem #634

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_

Expand Down Expand Up @@ -168,16 +168,16 @@ _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";
}
}

bool IsGoogleLoggingInitialized() {
return g_program_invocation_short_name != NULL;
return !g_program_invocation_short_name.empty();
}

#ifdef OS_WINDOWS
Expand Down Expand Up @@ -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
Expand Down