diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/base/logging.cc | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/runtime/base/logging.cc b/runtime/base/logging.cc index 3d842a0..3aabc8d 100644 --- a/runtime/base/logging.cc +++ b/runtime/base/logging.cc @@ -19,6 +19,7 @@ #include "base/mutex.h" #include "runtime.h" #include "thread-inl.h" +#include "UniquePtr.h" #include "utils.h" namespace art { @@ -28,20 +29,21 @@ LogVerbosity gLogVerbosity; unsigned int gAborting = 0; static LogSeverity gMinimumLogSeverity = INFO; -static std::string* gCmdLine = NULL; -static std::string* gProgramInvocationName = NULL; -static std::string* gProgramInvocationShortName = NULL; +static UniquePtr<std::string> gCmdLine; +static UniquePtr<std::string> gProgramInvocationName; +static UniquePtr<std::string> gProgramInvocationShortName; const char* GetCmdLine() { - return (gCmdLine != NULL) ? gCmdLine->c_str() : NULL; + return (gCmdLine.get() != nullptr) ? gCmdLine->c_str() : nullptr; } const char* ProgramInvocationName() { - return (gProgramInvocationName != NULL) ? gProgramInvocationName->c_str() : "art"; + return (gProgramInvocationName.get() != nullptr) ? gProgramInvocationName->c_str() : "art"; } const char* ProgramInvocationShortName() { - return (gProgramInvocationShortName != NULL) ? gProgramInvocationShortName->c_str() : "art"; + return (gProgramInvocationShortName.get() != nullptr) ? gProgramInvocationShortName->c_str() + : "art"; } // Configure logging based on ANDROID_LOG_TAGS environment variable. @@ -53,7 +55,7 @@ const char* ProgramInvocationShortName() { // and a letter indicating the minimum priority level we're expected to log. // This can be used to reveal or conceal logs with specific tags. void InitLogging(char* argv[]) { - if (gCmdLine != NULL) { + if (gCmdLine.get() != nullptr) { return; } // TODO: Move this to a more obvious InitART... @@ -63,17 +65,18 @@ void InitLogging(char* argv[]) { // but we don't have that luxury on the Mac, and there are a couple of argv[0] variants that are // commonly used. if (argv != NULL) { - gCmdLine = new std::string(argv[0]); + gCmdLine.reset(new std::string(argv[0])); for (size_t i = 1; argv[i] != NULL; ++i) { gCmdLine->append(" "); gCmdLine->append(argv[i]); } - gProgramInvocationName = new std::string(argv[0]); + gProgramInvocationName.reset(new std::string(argv[0])); const char* last_slash = strrchr(argv[0], '/'); - gProgramInvocationShortName = new std::string((last_slash != NULL) ? last_slash + 1 : argv[0]); + gProgramInvocationShortName.reset(new std::string((last_slash != NULL) ? last_slash + 1 + : argv[0])); } else { // TODO: fall back to /proc/self/cmdline when argv is NULL on Linux - gCmdLine = new std::string("<unset>"); + gCmdLine.reset(new std::string("<unset>")); } const char* tags = getenv("ANDROID_LOG_TAGS"); if (tags == NULL) { |