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

Unified Diff: runtime/platform/assert.h

Issue 850473002: MallocGrowableArray (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/vm/dart_entry_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/assert.h
===================================================================
--- runtime/platform/assert.h (revision 42760)
+++ runtime/platform/assert.h (working copy)
@@ -65,10 +65,10 @@
template<typename E, typename A>
void GreaterEqual(const E& left, const A& right);
+#endif
template<typename T>
- void NotNull(const T p);
-#endif
+ T NotNull(const T p);
private:
const char* const file_;
@@ -215,14 +215,15 @@
std::string es = ess.str(), as = ass.str();
Fail("expected: %s >= %s", es.c_str(), as.c_str());
}
+#endif
template<typename T>
-void DynamicAssertionHelper::NotNull(const T p) {
- if (p != NULL) return;
+T DynamicAssertionHelper::NotNull(const T p) {
+ if (p != NULL) return p;
Fail("expected: not NULL, found NULL");
+ return NULL;
}
-#endif
} // namespace dart
@@ -258,6 +259,11 @@
// mode.
#define DEBUG_ASSERT(cond) ASSERT(cond)
+// Returns 'ptr'; useful for initializer lists:
+// class Foo { Foo(int* ptr) : ptr_(ASSERT_NOTNULL(ptr)) ...
+#define ASSERT_NOTNULL(ptr) \
+ dart::Assert(__FILE__, __LINE__).NotNull((ptr))
+
#else // if defined(DEBUG)
// In order to avoid variable unused warnings for code that only uses
@@ -267,6 +273,8 @@
#define DEBUG_ASSERT(cond)
+#define ASSERT_NOTNULL(ptr) (ptr)
+
#endif // if defined(DEBUG)
« no previous file with comments | « no previous file | runtime/vm/dart_entry_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698