Index: webrtc/base/helpers.cc |
diff --git a/webrtc/base/helpers.cc b/webrtc/base/helpers.cc |
index e12ba107eac3e97b57e6364f97cf5a56d27e5e4c..0662b43b0ba170c309111253cd80b6a5c99277dc 100644 |
--- a/webrtc/base/helpers.cc |
+++ b/webrtc/base/helpers.cc |
@@ -17,13 +17,14 @@ |
#if defined(SSL_USE_OPENSSL) |
#include <openssl/rand.h> |
#elif defined(SSL_USE_NSS_RNG) |
-// Hack: Define+undefine int64 and uint64 to avoid typedef conflict with NSS. |
+// Hack: Define+undefine int64_t and uint64_t to avoid typedef conflict with |
+// NSS. |
// TODO(kjellander): Remove when webrtc:4497 is completed. |
-#define uint64 foo_uint64 |
-#define int64 foo_int64 |
+#define uint64_t foo_uint64 |
+#define int64_t foo_int64 |
#include "pk11func.h" |
-#undef uint64 |
-#undef int64 |
+#undef uint64_t |
+#undef int64_t |
#else |
#if defined(WEBRTC_WIN) |
#define WIN32_LEAN_AND_MEAN |
@@ -160,7 +161,7 @@ class TestRandomGenerator : public RandomGenerator { |
bool Init(const void* seed, size_t len) override { return true; } |
bool Generate(void* buf, size_t len) override { |
for (size_t i = 0; i < len; ++i) { |
- static_cast<uint8*>(buf)[i] = static_cast<uint8>(GetRandom()); |
+ static_cast<uint8_t*>(buf)[i] = static_cast<uint8_t>(GetRandom()); |
} |
return true; |
} |
@@ -227,7 +228,7 @@ bool CreateRandomString(size_t len, |
const char* table, int table_size, |
std::string* str) { |
str->clear(); |
- scoped_ptr<uint8[]> bytes(new uint8[len]); |
+ scoped_ptr<uint8_t[]> bytes(new uint8_t[len]); |
if (!Rng().Generate(bytes.get(), len)) { |
LOG(LS_ERROR) << "Failed to generate random string!"; |
return false; |
@@ -249,20 +250,20 @@ bool CreateRandomString(size_t len, const std::string& table, |
static_cast<int>(table.size()), str); |
} |
-uint32 CreateRandomId() { |
- uint32 id; |
+uint32_t CreateRandomId() { |
+ uint32_t id; |
if (!Rng().Generate(&id, sizeof(id))) { |
LOG(LS_ERROR) << "Failed to generate random id!"; |
} |
return id; |
} |
-uint64 CreateRandomId64() { |
- return static_cast<uint64>(CreateRandomId()) << 32 | CreateRandomId(); |
+uint64_t CreateRandomId64() { |
+ return static_cast<uint64_t>(CreateRandomId()) << 32 | CreateRandomId(); |
} |
-uint32 CreateRandomNonZeroId() { |
- uint32 id; |
+uint32_t CreateRandomNonZeroId() { |
+ uint32_t id; |
do { |
id = CreateRandomId(); |
} while (id == 0); |
@@ -270,8 +271,8 @@ uint32 CreateRandomNonZeroId() { |
} |
double CreateRandomDouble() { |
- return CreateRandomId() / (std::numeric_limits<uint32>::max() + |
- std::numeric_limits<double>::epsilon()); |
+ return CreateRandomId() / (std::numeric_limits<uint32_t>::max() + |
+ std::numeric_limits<double>::epsilon()); |
} |
} // namespace rtc |