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

Side by Side 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, 10 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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef PLATFORM_UTILS_H_ 5 #ifndef PLATFORM_UTILS_H_
6 #define PLATFORM_UTILS_H_ 6 #define PLATFORM_UTILS_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/globals.h" 9 #include "platform/globals.h"
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (IsDecimalDigit(c)) return c - '0'; 147 if (IsDecimalDigit(c)) return c - '0';
148 if (('A' <= c) && (c <= 'F')) return 10 + (c - 'A'); 148 if (('A' <= c) && (c <= 'F')) return 10 + (c - 'A');
149 return 10 + (c - 'a'); 149 return 10 + (c - 'a');
150 } 150 }
151 151
152 static char IntToHexDigit(int i) { 152 static char IntToHexDigit(int i) {
153 ASSERT(0 <= i && i < 16); 153 ASSERT(0 <= i && i < 16);
154 if (i < 10) return static_cast<char>('0' + i); 154 if (i < 10) return static_cast<char>('0' + i);
155 return static_cast<char>('A' + (i - 10)); 155 return static_cast<char>('A' + (i - 10));
156 } 156 }
157
158 // Perform a range check, checking if
159 // offset + count <= length
160 // without the risk of integer overflow.
161 static inline bool RangeCheck(intptr_t offset,
162 intptr_t count,
163 intptr_t length) {
164 return offset >= 0 &&
165 count >= 0 &&
166 length >= 0 &&
167 count <= (length - offset);
168 }
157 }; 169 };
158 170
159 } // namespace dart 171 } // namespace dart
160 172
161 #endif // PLATFORM_UTILS_H_ 173 #endif // PLATFORM_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698