Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/tcmalloc/chromium/src/internal_logging.h

Issue 10391178: 1. Enable large object pointer offset check in release build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/allocator/tcmalloc_unittest.cc ('k') | third_party/tcmalloc/chromium/src/tcmalloc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2005, Google Inc. 1 // Copyright (c) 2005, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 // Like assert(), but executed even in NDEBUG mode 107 // Like assert(), but executed even in NDEBUG mode
108 #undef CHECK_CONDITION 108 #undef CHECK_CONDITION
109 #define CHECK_CONDITION(cond) \ 109 #define CHECK_CONDITION(cond) \
110 do { \ 110 do { \
111 if (!(cond)) { \ 111 if (!(cond)) { \
112 ::tcmalloc::Log(::tcmalloc::kCrash, __FILE__, __LINE__, #cond); \ 112 ::tcmalloc::Log(::tcmalloc::kCrash, __FILE__, __LINE__, #cond); \
113 } \ 113 } \
114 } while (0) 114 } while (0)
115 115
116 #define CHECK_CONDITION_PRINT(cond, str) \
117 do { \
118 if (!(cond)) { \
119 ::tcmalloc::Log(::tcmalloc::kCrash, __FILE__, __LINE__, str); \
120 } \
121 } while (0)
122
116 // Our own version of assert() so we can avoid hanging by trying to do 123 // Our own version of assert() so we can avoid hanging by trying to do
117 // all kinds of goofy printing while holding the malloc lock. 124 // all kinds of goofy printing while holding the malloc lock.
118 #ifndef NDEBUG 125 #ifndef NDEBUG
119 #define ASSERT(cond) CHECK_CONDITION(cond) 126 #define ASSERT(cond) CHECK_CONDITION(cond)
127 #define ASSERT_PRINT(cond, str) CHECK_CONDITION_PRINT(cond, str)
120 #else 128 #else
121 #define ASSERT(cond) ((void) 0) 129 #define ASSERT(cond) ((void) 0)
130 #define ASSERT_PRINT(cond, str) ((void) 0)
122 #endif 131 #endif
123 132
124 // Print into buffer 133 // Print into buffer
125 class TCMalloc_Printer { 134 class TCMalloc_Printer {
126 private: 135 private:
127 char* buf_; // Where should we write next 136 char* buf_; // Where should we write next
128 int left_; // Space left in buffer (including space for \0) 137 int left_; // Space left in buffer (including space for \0)
129 138
130 public: 139 public:
131 // REQUIRES: "length > 0" 140 // REQUIRES: "length > 0"
132 TCMalloc_Printer(char* buf, int length) : buf_(buf), left_(length) { 141 TCMalloc_Printer(char* buf, int length) : buf_(buf), left_(length) {
133 buf[0] = '\0'; 142 buf[0] = '\0';
134 } 143 }
135 144
136 void printf(const char* format, ...) 145 void printf(const char* format, ...)
137 #ifdef HAVE___ATTRIBUTE__ 146 #ifdef HAVE___ATTRIBUTE__
138 __attribute__ ((__format__ (__printf__, 2, 3))) 147 __attribute__ ((__format__ (__printf__, 2, 3)))
139 #endif 148 #endif
140 ; 149 ;
141 }; 150 };
142 151
143 #endif // TCMALLOC_INTERNAL_LOGGING_H_ 152 #endif // TCMALLOC_INTERNAL_LOGGING_H_
OLDNEW
« no previous file with comments | « base/allocator/tcmalloc_unittest.cc ('k') | third_party/tcmalloc/chromium/src/tcmalloc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698