summaryrefslogtreecommitdiffstats
path: root/base/logging.h
diff options
context:
space:
mode:
authorakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-08 07:39:08 +0000
committerakalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-08 07:39:08 +0000
commit9c7132e60db51286c7499a8194c5b85a5762019b (patch)
tree90d75d97da13e5fc9c8b03f3efee8c708e008661 /base/logging.h
parent257493d2371e714358e1294ec390fda22a1b77c7 (diff)
downloadchromium_src-9c7132e60db51286c7499a8194c5b85a5762019b.zip
chromium_src-9c7132e60db51286c7499a8194c5b85a5762019b.tar.gz
chromium_src-9c7132e60db51286c7499a8194c5b85a5762019b.tar.bz2
[Logging] Remove unneeded CheckOpString struct for CHECKs
Using string* directly works. Made LogMessage delete any passed in string* after it uses it. Removed suppressions for fixed memory leak. BUG=57683 TEST=Existing unit tests Review URL: http://codereview.chromium.org/6413032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74100 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/logging.h')
-rw-r--r--base/logging.h26
1 files changed, 9 insertions, 17 deletions
diff --git a/base/logging.h b/base/logging.h
index 771aa73..b1bc0b0 100644
--- a/base/logging.h
+++ b/base/logging.h
@@ -436,19 +436,10 @@ const LogSeverity LOG_0 = LOG_ERROR;
LAZY_STREAM(PLOG_STREAM(FATAL), !(condition)) \
<< "Check failed: " #condition ". "
-// A container for a string pointer which can be evaluated to a bool -
-// true iff the pointer is NULL.
-struct CheckOpString {
- CheckOpString(std::string* str) : str_(str) { }
- // No destructor: if str_ is non-NULL, we're about to LOG(FATAL),
- // so there's no point in cleaning up str_.
- operator bool() const { return str_ != NULL; }
- std::string* str_;
-};
-
// Build the error message string. This is separate from the "Impl"
// function template because it is not performance critical and so can
-// be out of line, while the "Impl" code should be inline.
+// be out of line, while the "Impl" code should be inline. Caller
+// takes ownership of the returned string.
template<class t1, class t2>
std::string* MakeCheckOpString(const t1& v1, const t2& v2, const char* names) {
std::ostringstream ss;
@@ -479,7 +470,7 @@ extern template std::string* MakeCheckOpString<std::string, std::string>(
// TODO(akalin): Rewrite this so that constructs like if (...)
// CHECK_EQ(...) else { ... } work properly.
#define CHECK_OP(name, op, val1, val2) \
- if (logging::CheckOpString _result = \
+ if (std::string* _result = \
logging::Check##name##Impl((val1), (val2), \
#val1 " " #op " " #val2)) \
logging::LogMessage(__FILE__, __LINE__, _result).stream()
@@ -655,7 +646,7 @@ const LogSeverity LOG_DCHECK = LOG_INFO;
// Don't use this macro directly in your code, use DCHECK_EQ et al below.
#define DCHECK_OP(name, op, val1, val2) \
if (DCHECK_IS_ON()) \
- if (logging::CheckOpString _result = \
+ if (std::string* _result = \
logging::Check##name##Impl((val1), (val2), \
#val1 " " #op " " #val2)) \
logging::LogMessage( \
@@ -723,14 +714,15 @@ class LogMessage {
// saves a couple of bytes per call site.
LogMessage(const char* file, int line, LogSeverity severity);
- // A special constructor used for check failures.
+ // A special constructor used for check failures. Takes ownership
+ // of the given string.
// Implied severity = LOG_FATAL
- LogMessage(const char* file, int line, const CheckOpString& result);
+ LogMessage(const char* file, int line, std::string* result);
// A special constructor used for check failures, with the option to
- // specify severity.
+ // specify severity. Takes ownership of the given string.
LogMessage(const char* file, int line, LogSeverity severity,
- const CheckOpString& result);
+ std::string* result);
~LogMessage();