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

Unified Diff: src/utils.h

Issue 390004: Fix warnings on Win64. (Closed)
Patch Set: Created 11 years, 1 month 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
« src/api.cc ('K') | « src/spaces.cc ('k') | src/utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils.h
diff --git a/src/utils.h b/src/utils.h
index f4a0598c20368b1ae7e936d43196bd74f8e5f22f..c271ae17f74de8aa33a694641238c62e03aafb61 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -66,7 +66,7 @@ static inline intptr_t OffsetFrom(T x) {
// integral types.
template <typename T>
static inline T AddressFrom(intptr_t x) {
- return static_cast<T>(0) + x;
+ return static_cast<T>(static_cast<T>(0) + x);
}
@@ -137,6 +137,13 @@ static T Min(T a, T b) {
}
+inline int StrLength(const char* string) {
+ size_t length = strlen(string);
+ ASSERT(length == static_cast<size_t>(static_cast<int>(length)));
+ return static_cast<int>(length);
+}
+
+
// ----------------------------------------------------------------------------
// BitField is a help template for encoding and decode bitfield with
// unsigned content.
@@ -449,15 +456,15 @@ class ScopedVector : public Vector<T> {
inline Vector<const char> CStrVector(const char* data) {
- return Vector<const char>(data, static_cast<int>(strlen(data)));
+ return Vector<const char>(data, StrLength(data));
}
inline Vector<char> MutableCStrVector(char* data) {
- return Vector<char>(data, static_cast<int>(strlen(data)));
+ return Vector<char>(data, StrLength(data));
}
inline Vector<char> MutableCStrVector(char* data, int max) {
- int length = static_cast<int>(strlen(data));
+ int length = StrLength(data);
return Vector<char>(data, (length < max) ? length : max);
}
« src/api.cc ('K') | « src/spaces.cc ('k') | src/utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698