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

Unified Diff: runtime/platform/utils.h

Issue 9235067: Use ByteArray's native for Socket and File. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 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
Index: runtime/platform/utils.h
===================================================================
--- runtime/platform/utils.h (revision 3811)
+++ runtime/platform/utils.h (working copy)
@@ -154,6 +154,18 @@
if (i < 10) return static_cast<char>('0' + i);
return static_cast<char>('A' + (i - 10));
}
+
+ // Perform a range check, checking if
+ // offset + count <= length
+ // without the risk of integer overflow.
+ static inline bool RangeCheck(intptr_t offset,
+ intptr_t count,
+ intptr_t length) {
+ return offset >= 0 &&
+ count >= 0 &&
+ length >= 0 &&
+ count <= (length - offset);
+ }
};
} // namespace dart

Powered by Google App Engine
This is Rietveld 408576698