Convert usage of ARRAY_SIZE to arraysize.
ARRAY_SIZE is the old version of arraysize and does not cover
all the cases in C++, arraysize is a copy of Chromium's
version and thus have wider coverage.
BUG=None
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/1405023016
Cr-Original-Commit-Position: refs/heads/master@{#10594}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 5237aaf243d29732f59557361b7a993c0a18cf0e
diff --git a/base/bitbuffer_unittest.cc b/base/bitbuffer_unittest.cc
index 99701f7..ce42257 100644
--- a/base/bitbuffer_unittest.cc
+++ b/base/bitbuffer_unittest.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/bitbuffer.h"
#include "webrtc/base/bytebuffer.h"
#include "webrtc/base/common.h"
@@ -301,11 +302,11 @@
char test_string[] = "my precious";
uint8_t bytes[64] = {0};
BitBufferWriter buffer(bytes, 64);
- for (size_t i = 0; i < ARRAY_SIZE(test_string); ++i) {
+ for (size_t i = 0; i < arraysize(test_string); ++i) {
EXPECT_TRUE(buffer.WriteExponentialGolomb(test_string[i]));
}
buffer.Seek(0, 0);
- for (size_t i = 0; i < ARRAY_SIZE(test_string); ++i) {
+ for (size_t i = 0; i < arraysize(test_string); ++i) {
uint32_t val;
EXPECT_TRUE(buffer.ReadExponentialGolomb(&val));
EXPECT_LE(val, std::numeric_limits<uint8_t>::max());
diff --git a/base/bytebuffer_unittest.cc b/base/bytebuffer_unittest.cc
index 56b0e05..0287d85 100644
--- a/base/bytebuffer_unittest.cc
+++ b/base/bytebuffer_unittest.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/bytebuffer.h"
#include "webrtc/base/byteorder.h"
#include "webrtc/base/common.h"
@@ -114,7 +115,7 @@
TEST(ByteBufferTest, TestReadWriteBuffer) {
ByteBuffer::ByteOrder orders[2] = { ByteBuffer::ORDER_HOST,
ByteBuffer::ORDER_NETWORK };
- for (size_t i = 0; i < ARRAY_SIZE(orders); i++) {
+ for (size_t i = 0; i < arraysize(orders); i++) {
ByteBuffer buffer(orders[i]);
EXPECT_EQ(orders[i], buffer.Order());
uint8_t ru8;
diff --git a/base/common.h b/base/common.h
index 67665f2..2086754 100644
--- a/base/common.h
+++ b/base/common.h
@@ -54,8 +54,6 @@
#endif // !defined(WEBRTC_WIN)
-#define ARRAY_SIZE(x) (static_cast<int>(sizeof(x) / sizeof(x[0])))
-
/////////////////////////////////////////////////////////////////////////////
// Assertions
/////////////////////////////////////////////////////////////////////////////
diff --git a/base/crc32.cc b/base/crc32.cc
index eae338a..f9e4c37 100644
--- a/base/crc32.cc
+++ b/base/crc32.cc
@@ -10,6 +10,7 @@
#include "webrtc/base/crc32.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/basicdefs.h"
namespace rtc {
@@ -22,9 +23,9 @@
static uint32_t kCrc32Table[256] = {0};
static void EnsureCrc32TableInited() {
- if (kCrc32Table[ARRAY_SIZE(kCrc32Table) - 1])
+ if (kCrc32Table[arraysize(kCrc32Table) - 1])
return; // already inited
- for (uint32_t i = 0; i < ARRAY_SIZE(kCrc32Table); ++i) {
+ for (uint32_t i = 0; i < arraysize(kCrc32Table); ++i) {
uint32_t c = i;
for (size_t j = 0; j < 8; ++j) {
if (c & 1) {
diff --git a/base/diskcache.cc b/base/diskcache.cc
index 7bf1ba2..a1fba6a 100644
--- a/base/diskcache.cc
+++ b/base/diskcache.cc
@@ -15,6 +15,7 @@
#endif
#include <algorithm>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/diskcache.h"
#include "webrtc/base/fileutils.h"
@@ -263,7 +264,7 @@
#endif // !TRANSPARENT_CACHE_NAMES
char extension[32];
- sprintfn(extension, ARRAY_SIZE(extension), ".%u", index);
+ sprintfn(extension, arraysize(extension), ".%u", index);
Pathname pathname;
pathname.SetFolder(folder_);
diff --git a/base/fileutils.cc b/base/fileutils.cc
index 6f385d7..cb23153 100644
--- a/base/fileutils.cc
+++ b/base/fileutils.cc
@@ -10,6 +10,7 @@
#include <assert.h>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/pathutils.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/stringutils.h"
@@ -273,8 +274,8 @@
}
version += 1;
char version_base[MAX_PATH];
- sprintfn(version_base, ARRAY_SIZE(version_base), "%s-%u",
- basename.c_str(), version);
+ sprintfn(version_base, arraysize(version_base), "%s-%u", basename.c_str(),
+ version);
path.SetBasename(version_base);
}
return true;
diff --git a/base/httpcommon-inl.h b/base/httpcommon-inl.h
index d1c0bf0..188d9e6 100644
--- a/base/httpcommon-inl.h
+++ b/base/httpcommon-inl.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_BASE_HTTPCOMMON_INL_H__
#define WEBRTC_BASE_HTTPCOMMON_INL_H__
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/httpcommon.h"
@@ -80,7 +81,7 @@
template<class CTYPE>
void Url<CTYPE>::do_get_url(string* val) const {
CTYPE protocol[9];
- asccpyn(protocol, ARRAY_SIZE(protocol), secure_ ? "https://" : "http://");
+ asccpyn(protocol, arraysize(protocol), secure_ ? "https://" : "http://");
val->append(protocol);
do_get_address(val);
do_get_full_path(val);
@@ -91,8 +92,8 @@
val->append(host_);
if (port_ != HttpDefaultPort(secure_)) {
CTYPE format[5], port[32];
- asccpyn(format, ARRAY_SIZE(format), ":%hu");
- sprintfn(port, ARRAY_SIZE(port), format, port_);
+ asccpyn(format, arraysize(format), ":%hu");
+ sprintfn(port, arraysize(port), format, port_);
val->append(port);
}
}
diff --git a/base/httpcommon.cc b/base/httpcommon.cc
index 0c3547e..c90bea5 100644
--- a/base/httpcommon.cc
+++ b/base/httpcommon.cc
@@ -21,6 +21,7 @@
#include <algorithm>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/base64.h"
#include "webrtc/base/common.h"
#include "webrtc/base/cryptstring.h"
@@ -377,7 +378,7 @@
gmt = non_gmt + ((zone[0] == '+') ? offset : -offset);
} else {
size_t zindex;
- if (!find_string(zindex, zone, kTimeZones, ARRAY_SIZE(kTimeZones))) {
+ if (!find_string(zindex, zone, kTimeZones, arraysize(kTimeZones))) {
return false;
}
gmt = non_gmt + kTimeZoneOffsets[zindex] * 60 * 60;
diff --git a/base/natsocketfactory.cc b/base/natsocketfactory.cc
index 548a80c..0abd2a1 100644
--- a/base/natsocketfactory.cc
+++ b/base/natsocketfactory.cc
@@ -10,6 +10,7 @@
#include "webrtc/base/natsocketfactory.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/natserver.h"
#include "webrtc/base/virtualsocketserver.h"
@@ -270,7 +271,7 @@
// Sends the destination address to the server to tell it to connect.
void SendConnectRequest() {
char buf[kNATEncodedIPv6AddressSize];
- size_t length = PackAddressForNAT(buf, ARRAY_SIZE(buf), remote_addr_);
+ size_t length = PackAddressForNAT(buf, arraysize(buf), remote_addr_);
socket_->Send(buf, length);
}
diff --git a/base/openssladapter.cc b/base/openssladapter.cc
index 892b5cc..1f5fbbc 100644
--- a/base/openssladapter.cc
+++ b/base/openssladapter.cc
@@ -31,6 +31,7 @@
#include "config.h"
#endif // HAVE_CONFIG_H
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/openssl.h"
@@ -915,7 +916,7 @@
bool OpenSSLAdapter::ConfigureTrustedRootCertificates(SSL_CTX* ctx) {
// Add the root cert that we care about to the SSL context
int count_of_added_certs = 0;
- for (int i = 0; i < ARRAY_SIZE(kSSLCertCertificateList); i++) {
+ for (size_t i = 0; i < arraysize(kSSLCertCertificateList); i++) {
const unsigned char* cert_buffer = kSSLCertCertificateList[i];
size_t cert_buffer_len = kSSLCertCertificateSizeList[i];
X509* cert = d2i_X509(NULL, &cert_buffer,
diff --git a/base/physicalsocketserver.cc b/base/physicalsocketserver.cc
index e0fe8a0..4a4c0a3 100644
--- a/base/physicalsocketserver.cc
+++ b/base/physicalsocketserver.cc
@@ -39,6 +39,7 @@
#include <algorithm>
#include <map>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/byteorder.h"
#include "webrtc/base/common.h"
@@ -628,8 +629,8 @@
// Returns true if the given signal number is set.
bool IsSignalSet(int signum) const {
- ASSERT(signum < ARRAY_SIZE(received_signal_));
- if (signum < ARRAY_SIZE(received_signal_)) {
+ ASSERT(signum < static_cast<int>(arraysize(received_signal_)));
+ if (signum < static_cast<int>(arraysize(received_signal_))) {
return received_signal_[signum];
} else {
return false;
@@ -638,8 +639,8 @@
// Clears the given signal number.
void ClearSignal(int signum) {
- ASSERT(signum < ARRAY_SIZE(received_signal_));
- if (signum < ARRAY_SIZE(received_signal_)) {
+ ASSERT(signum < static_cast<int>(arraysize(received_signal_)));
+ if (signum < static_cast<int>(arraysize(received_signal_))) {
received_signal_[signum] = false;
}
}
@@ -654,7 +655,7 @@
// user-level state of the process, since the handler could be executed at any
// time on any thread.
void OnPosixSignalReceived(int signum) {
- if (signum >= ARRAY_SIZE(received_signal_)) {
+ if (signum >= static_cast<int>(arraysize(received_signal_))) {
// We don't have space in our array for this.
return;
}
diff --git a/base/proxydetect.cc b/base/proxydetect.cc
index c0cfab9..30959ca 100644
--- a/base/proxydetect.cc
+++ b/base/proxydetect.cc
@@ -34,6 +34,7 @@
#include <map>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/httpcommon.h"
#include "webrtc/base/httpcommon-inl.h"
@@ -398,7 +399,7 @@
}
char buffer[NAME_MAX + 1];
if (0 != FSRefMakePath(&fr, reinterpret_cast<uint8_t*>(buffer),
- ARRAY_SIZE(buffer))) {
+ arraysize(buffer))) {
LOG(LS_ERROR) << "FSRefMakePath failed";
return false;
}
diff --git a/base/socket_unittest.cc b/base/socket_unittest.cc
index d078d7c..8143823 100644
--- a/base/socket_unittest.cc
+++ b/base/socket_unittest.cc
@@ -10,6 +10,7 @@
#include "webrtc/base/socket_unittest.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/asyncudpsocket.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/nethelpers.h"
@@ -827,7 +828,7 @@
// Fill the socket buffer.
char buf[1024 * 16] = {0};
int sends = 0;
- while (++sends && accepted->Send(&buf, ARRAY_SIZE(buf)) != -1) {}
+ while (++sends && accepted->Send(&buf, arraysize(buf)) != -1) {}
EXPECT_TRUE(accepted->IsBlocking());
// Wait until data is available.
@@ -835,7 +836,7 @@
// Pull data.
for (int i = 0; i < sends; ++i) {
- client->Recv(buf, ARRAY_SIZE(buf));
+ client->Recv(buf, arraysize(buf));
}
// Expect at least one additional writable callback.
@@ -845,7 +846,7 @@
// callbacks.
int extras = 0;
for (int i = 0; i < 100; ++i) {
- accepted->Send(&buf, ARRAY_SIZE(buf));
+ accepted->Send(&buf, arraysize(buf));
rtc::Thread::Current()->ProcessMessages(1);
if (sink.Check(accepted.get(), testing::SSE_WRITE)) {
extras++;
diff --git a/base/stringencode_unittest.cc b/base/stringencode_unittest.cc
index 406d9c7..588e9d8 100644
--- a/base/stringencode_unittest.cc
+++ b/base/stringencode_unittest.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/stringencode.h"
@@ -48,7 +49,7 @@
}
char buffer[5];
- memset(buffer, 0x01, ARRAY_SIZE(buffer));
+ memset(buffer, 0x01, arraysize(buffer));
ASSERT_EQ(kTests[i].enclen, utf8_encode(buffer,
kTests[i].encsize,
kTests[i].decoded));
@@ -56,7 +57,7 @@
// Make sure remainder of buffer is unchanged
ASSERT_TRUE(memory_check(buffer + kTests[i].enclen,
0x1,
- ARRAY_SIZE(buffer) - kTests[i].enclen));
+ arraysize(buffer) - kTests[i].enclen));
}
}
diff --git a/base/task_unittest.cc b/base/task_unittest.cc
index 7f67841..3508219 100644
--- a/base/task_unittest.cc
+++ b/base/task_unittest.cc
@@ -20,6 +20,7 @@
#include "webrtc/base/win32.h"
#endif // WEBRTC_WIN
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/logging.h"
@@ -408,7 +409,7 @@
class TimeoutChangeTest : public sigslot::has_slots<> {
public:
TimeoutChangeTest()
- : task_count_(ARRAY_SIZE(stuck_tasks_)) {}
+ : task_count_(arraysize(stuck_tasks_)) {}
// no need to delete any tasks; the task runner owns them
~TimeoutChangeTest() {}
@@ -463,7 +464,7 @@
private:
void OnTimeoutId(const int id) {
- for (int i = 0; i < ARRAY_SIZE(stuck_tasks_); ++i) {
+ for (size_t i = 0; i < arraysize(stuck_tasks_); ++i) {
if (stuck_tasks_[i] && stuck_tasks_[i]->unique_id() == id) {
task_count_--;
stuck_tasks_[i] = NULL;
diff --git a/base/testutils.h b/base/testutils.h
index e56895d..6e7e22a 100644
--- a/base/testutils.h
+++ b/base/testutils.h
@@ -25,6 +25,7 @@
#include <algorithm>
#include <map>
#include <vector>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/asyncsocket.h"
#include "webrtc/base/common.h"
#include "webrtc/base/gunit.h"
@@ -357,7 +358,7 @@
}
void OnReadEvent(AsyncSocket* socket) {
char data[64 * 1024];
- int result = socket_->Recv(data, ARRAY_SIZE(data));
+ int result = socket_->Recv(data, arraysize(data));
if (result > 0) {
recv_buffer_.insert(recv_buffer_.end(), data, data + result);
}
diff --git a/base/unixfilesystem.cc b/base/unixfilesystem.cc
index 30d6e78..734e880 100644
--- a/base/unixfilesystem.cc
+++ b/base/unixfilesystem.cc
@@ -44,6 +44,7 @@
#include <sys/syslimits.h>
#endif
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/pathutils.h"
#include "webrtc/base/stream.h"
@@ -176,7 +177,7 @@
kCreateFolder, &fr))
return false;
unsigned char buffer[NAME_MAX+1];
- if (0 != FSRefMakePath(&fr, buffer, ARRAY_SIZE(buffer)))
+ if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer)))
return false;
pathname.SetPathname(reinterpret_cast<char*>(buffer), "");
#elif defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS)
@@ -303,7 +304,7 @@
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
#endif // WEBRTC_ANDROID || WEBRTC_IOS
};
- for (size_t i = 0; i < ARRAY_SIZE(kTempPrefixes); ++i) {
+ for (size_t i = 0; i < arraysize(kTempPrefixes); ++i) {
if (0 == strncmp(pathname.pathname().c_str(), kTempPrefixes[i],
strlen(kTempPrefixes[i])))
return true;
@@ -377,7 +378,7 @@
return true;
#else // WEBRTC_MAC && !defined(WEBRTC_IOS)
char buffer[PATH_MAX + 2];
- ssize_t len = readlink("/proc/self/exe", buffer, ARRAY_SIZE(buffer) - 1);
+ ssize_t len = readlink("/proc/self/exe", buffer, arraysize(buffer) - 1);
if ((len <= 0) || (len == PATH_MAX + 1))
return false;
buffer[len] = '\0';
@@ -399,7 +400,7 @@
kCreateFolder, &fr))
return false;
unsigned char buffer[NAME_MAX+1];
- if (0 != FSRefMakePath(&fr, buffer, ARRAY_SIZE(buffer)))
+ if (0 != FSRefMakePath(&fr, buffer, arraysize(buffer)))
return false;
path->SetPathname(reinterpret_cast<char*>(buffer), "");
} else {
@@ -487,7 +488,7 @@
// Create a random directory as /tmp/<appname>-<pid>-<timestamp>
char buffer[128];
- sprintfn(buffer, ARRAY_SIZE(buffer), "-%d-%d",
+ sprintfn(buffer, arraysize(buffer), "-%d-%d",
static_cast<int>(getpid()),
static_cast<int>(time(0)));
std::string folder(application_name_);
diff --git a/base/urlencode_unittest.cc b/base/urlencode_unittest.cc
index 5216913..6a61db3 100644
--- a/base/urlencode_unittest.cc
+++ b/base/urlencode_unittest.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/thread.h"
@@ -19,7 +20,7 @@
char source[] = "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^";
char dest[1];
- ASSERT_EQ(0, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+ ASSERT_EQ(0, UrlEncode(source, dest, arraysize(dest)));
ASSERT_EQ('\0', dest[0]);
dest[0] = 'a';
@@ -30,7 +31,7 @@
TEST(Urlencode, OneCharacterConversion) {
char source[] = "^";
char dest[4];
- ASSERT_EQ(3, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+ ASSERT_EQ(3, UrlEncode(source, dest, arraysize(dest)));
ASSERT_STREQ("%5E", dest);
}
@@ -40,7 +41,7 @@
// hold the text given.
char source[] = "aa";
char dest[3];
- ASSERT_EQ(2, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+ ASSERT_EQ(2, UrlEncode(source, dest, arraysize(dest)));
ASSERT_STREQ("aa", dest);
}
@@ -49,14 +50,14 @@
// big enough to hold the encoding.
char source[] = "&";
char dest[3];
- ASSERT_EQ(0, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+ ASSERT_EQ(0, UrlEncode(source, dest, arraysize(dest)));
ASSERT_EQ('\0', dest[0]);
}
TEST(Urlencode, Encoding1) {
char source[] = "A^ ";
char dest[8];
- ASSERT_EQ(5, UrlEncode(source, dest, ARRAY_SIZE(dest)));
+ ASSERT_EQ(5, UrlEncode(source, dest, arraysize(dest)));
ASSERT_STREQ("A%5E+", dest);
}
@@ -64,7 +65,7 @@
char source[] = "A^ ";
char dest[8];
ASSERT_EQ(7, rtc::UrlEncodeWithoutEncodingSpaceAsPlus(source, dest,
- ARRAY_SIZE(dest)));
+ arraysize(dest)));
ASSERT_STREQ("A%5E%20", dest);
}
diff --git a/base/virtualsocket_unittest.cc b/base/virtualsocket_unittest.cc
index 694b154..68ad23b 100644
--- a/base/virtualsocket_unittest.cc
+++ b/base/virtualsocket_unittest.cc
@@ -14,6 +14,7 @@
#include <netinet/in.h>
#endif
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/testclient.h"
@@ -1022,9 +1023,9 @@
const double kTestDev[] = { 0.25, 0.1, 0.01 };
// TODO: The current code only works for 1000 data points or more.
const uint32_t kTestSamples[] = {/*10, 100,*/ 1000};
- for (size_t midx = 0; midx < ARRAY_SIZE(kTestMean); ++midx) {
- for (size_t didx = 0; didx < ARRAY_SIZE(kTestDev); ++didx) {
- for (size_t sidx = 0; sidx < ARRAY_SIZE(kTestSamples); ++sidx) {
+ for (size_t midx = 0; midx < arraysize(kTestMean); ++midx) {
+ for (size_t didx = 0; didx < arraysize(kTestDev); ++didx) {
+ for (size_t sidx = 0; sidx < arraysize(kTestSamples); ++sidx) {
ASSERT_LT(0u, kTestSamples[sidx]);
const uint32_t kStdDev =
static_cast<uint32_t>(kTestDev[didx] * kTestMean[midx]);
diff --git a/base/win32.cc b/base/win32.cc
index 6e09829..182b84f 100644
--- a/base/win32.cc
+++ b/base/win32.cc
@@ -14,6 +14,7 @@
#include <ws2tcpip.h>
#include <algorithm>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/byteorder.h"
#include "webrtc/base/common.h"
@@ -87,7 +88,7 @@
int current = 1;
int max = 0;
int maxpos = -1;
- int run_array_size = ARRAY_SIZE(runpos);
+ int run_array_size = arraysize(runpos);
// Run over the address marking runs of 0s.
for (int i = 0; i < run_array_size; ++i) {
if (as_shorts[i] == 0) {
diff --git a/base/win32filesystem.cc b/base/win32filesystem.cc
index 8ac918f..b731974 100644
--- a/base/win32filesystem.cc
+++ b/base/win32filesystem.cc
@@ -15,6 +15,7 @@
#include <shlobj.h>
#include <tchar.h>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/pathutils.h"
#include "webrtc/base/scoped_ptr.h"
@@ -197,16 +198,16 @@
bool Win32Filesystem::GetTemporaryFolder(Pathname &pathname, bool create,
const std::string *append) {
wchar_t buffer[MAX_PATH + 1];
- if (!::GetTempPath(ARRAY_SIZE(buffer), buffer))
+ if (!::GetTempPath(arraysize(buffer), buffer))
return false;
if (!IsCurrentProcessLowIntegrity() &&
- !::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
+ !::GetLongPathName(buffer, buffer, arraysize(buffer)))
return false;
size_t len = strlen(buffer);
if ((len > 0) && (buffer[len-1] != '\\')) {
- len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, L"\\");
+ len += strcpyn(buffer + len, arraysize(buffer) - len, L"\\");
}
- if (len >= ARRAY_SIZE(buffer) - 1)
+ if (len >= arraysize(buffer) - 1)
return false;
pathname.clear();
pathname.SetFolder(ToUtf8(buffer));
@@ -295,10 +296,10 @@
bool Win32Filesystem::IsTemporaryPath(const Pathname& pathname) {
TCHAR buffer[MAX_PATH + 1];
- if (!::GetTempPath(ARRAY_SIZE(buffer), buffer))
+ if (!::GetTempPath(arraysize(buffer), buffer))
return false;
if (!IsCurrentProcessLowIntegrity() &&
- !::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
+ !::GetLongPathName(buffer, buffer, arraysize(buffer)))
return false;
return (::strnicmp(ToUtf16(pathname.pathname()).c_str(),
buffer, strlen(buffer)) == 0);
@@ -337,7 +338,7 @@
bool Win32Filesystem::GetAppPathname(Pathname* path) {
TCHAR buffer[MAX_PATH + 1];
- if (0 == ::GetModuleFileName(NULL, buffer, ARRAY_SIZE(buffer)))
+ if (0 == ::GetModuleFileName(NULL, buffer, arraysize(buffer)))
return false;
path->SetPathname(ToUtf8(buffer));
return true;
@@ -351,20 +352,20 @@
if (!::SHGetSpecialFolderPath(NULL, buffer, csidl, TRUE))
return false;
if (!IsCurrentProcessLowIntegrity() &&
- !::GetLongPathName(buffer, buffer, ARRAY_SIZE(buffer)))
+ !::GetLongPathName(buffer, buffer, arraysize(buffer)))
return false;
- size_t len = strcatn(buffer, ARRAY_SIZE(buffer), __T("\\"));
- len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len,
+ size_t len = strcatn(buffer, arraysize(buffer), __T("\\"));
+ len += strcpyn(buffer + len, arraysize(buffer) - len,
ToUtf16(organization_name_).c_str());
if ((len > 0) && (buffer[len-1] != __T('\\'))) {
- len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, __T("\\"));
+ len += strcpyn(buffer + len, arraysize(buffer) - len, __T("\\"));
}
- len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len,
+ len += strcpyn(buffer + len, arraysize(buffer) - len,
ToUtf16(application_name_).c_str());
if ((len > 0) && (buffer[len-1] != __T('\\'))) {
- len += strcpyn(buffer + len, ARRAY_SIZE(buffer) - len, __T("\\"));
+ len += strcpyn(buffer + len, arraysize(buffer) - len, __T("\\"));
}
- if (len >= ARRAY_SIZE(buffer) - 1)
+ if (len >= arraysize(buffer) - 1)
return false;
path->clear();
path->SetFolder(ToUtf8(buffer));
diff --git a/base/win32regkey_unittest.cc b/base/win32regkey_unittest.cc
index 389c3a2..1702ef7 100644
--- a/base/win32regkey_unittest.cc
+++ b/base/win32regkey_unittest.cc
@@ -10,6 +10,7 @@
// Unittest for registry access API
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/common.h"
#include "webrtc/base/win32regkey.h"
@@ -564,8 +565,8 @@
#ifdef IS_PRIVATE_BUILD
// get a temp file name
wchar_t temp_path[MAX_PATH] = {0};
- EXPECT_LT(::GetTempPath(ARRAY_SIZE(temp_path), temp_path),
- static_cast<DWORD>(ARRAY_SIZE(temp_path)));
+ EXPECT_LT(::GetTempPath(arraysize(temp_path), temp_path),
+ static_cast<DWORD>(arraysize(temp_path)));
wchar_t temp_file[MAX_PATH] = {0};
EXPECT_NE(::GetTempFileName(temp_path, L"rkut_",
::GetTickCount(), temp_file), 0);
diff --git a/base/win32windowpicker.cc b/base/win32windowpicker.cc
index b4550ae..da05a5c 100644
--- a/base/win32windowpicker.cc
+++ b/base/win32windowpicker.cc
@@ -12,6 +12,7 @@
#include <string>
#include <vector>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
@@ -58,7 +59,7 @@
}
TCHAR window_title[500];
- GetWindowText(hwnd, window_title, ARRAY_SIZE(window_title));
+ GetWindowText(hwnd, window_title, arraysize(window_title));
std::string title = ToUtf8(window_title);
WindowId id(hwnd);
diff --git a/base/win32windowpicker_unittest.cc b/base/win32windowpicker_unittest.cc
index 71e8af6..701bb27 100644
--- a/base/win32windowpicker_unittest.cc
+++ b/base/win32windowpicker_unittest.cc
@@ -7,6 +7,7 @@
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
@@ -71,7 +72,7 @@
EXPECT_EQ(window_picker.visible_window()->handle(), desc.id().id());
TCHAR window_title[500];
GetWindowText(window_picker.visible_window()->handle(), window_title,
- ARRAY_SIZE(window_title));
+ arraysize(window_title));
EXPECT_EQ(0, wcscmp(window_title, kVisibleWindowTitle));
}
diff --git a/examples/peerconnection/client/defaults.cc b/examples/peerconnection/client/defaults.cc
index 3090c15..f70aa72 100644
--- a/examples/peerconnection/client/defaults.cc
+++ b/examples/peerconnection/client/defaults.cc
@@ -19,6 +19,7 @@
#include <unistd.h>
#endif
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
const char kAudioLabel[] = "audio_label";
@@ -49,7 +50,7 @@
std::string GetPeerName() {
char computer_name[256];
- if (gethostname(computer_name, ARRAY_SIZE(computer_name)) != 0)
+ if (gethostname(computer_name, arraysize(computer_name)) != 0)
strcpy(computer_name, "host");
std::string ret(GetEnvVarOrDefault("USERNAME", "user"));
ret += '@';
diff --git a/examples/peerconnection/client/main_wnd.cc b/examples/peerconnection/client/main_wnd.cc
index 30b12a8..72f85b9 100644
--- a/examples/peerconnection/client/main_wnd.cc
+++ b/examples/peerconnection/client/main_wnd.cc
@@ -13,6 +13,7 @@
#include <math.h>
#include "webrtc/examples/peerconnection/client/defaults.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
@@ -241,7 +242,7 @@
// Set the map mode so that the ratio will be maintained for us.
HDC all_dc[] = { ps.hdc, dc_mem };
- for (int i = 0; i < ARRAY_SIZE(all_dc); ++i) {
+ for (int i = 0; i < arraysize(all_dc); ++i) {
SetMapMode(all_dc[i], MM_ISOTROPIC);
SetWindowExtEx(all_dc[i], width, height, NULL);
SetViewportExtEx(all_dc[i], rc.right, rc.bottom, NULL);
diff --git a/libjingle/xmpp/chatroommoduleimpl.cc b/libjingle/xmpp/chatroommoduleimpl.cc
index 546aa75..52fba4c 100644
--- a/libjingle/xmpp/chatroommoduleimpl.cc
+++ b/libjingle/xmpp/chatroommoduleimpl.cc
@@ -17,6 +17,7 @@
#include "webrtc/libjingle/xmpp/chatroommodule.h"
#include "webrtc/libjingle/xmpp/constants.h"
#include "webrtc/libjingle/xmpp/moduleimpl.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
namespace buzz {
@@ -535,7 +536,7 @@
// find the right transition description
StateTransitionDescription* transition_desc = NULL;
- for (int i=0; i < ARRAY_SIZE(Transitions); i++) {
+ for (size_t i = 0; i < arraysize(Transitions); i++) {
if (Transitions[i].old_state == old_state &&
Transitions[i].new_state == new_state) {
transition_desc = &Transitions[i];
diff --git a/libjingle/xmpp/presenceouttask.cc b/libjingle/xmpp/presenceouttask.cc
index aa19c9d..5519a4f 100644
--- a/libjingle/xmpp/presenceouttask.cc
+++ b/libjingle/xmpp/presenceouttask.cc
@@ -13,6 +13,7 @@
#include "webrtc/libjingle/xmpp/constants.h"
#include "webrtc/libjingle/xmpp/presenceouttask.h"
#include "webrtc/libjingle/xmpp/xmppclient.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/stringencode.h"
namespace buzz {
@@ -128,7 +129,7 @@
time(¤t_time_seconds);
struct tm* current_time = gmtime(¤t_time_seconds);
char output[256];
- strftime(output, ARRAY_SIZE(output), "%Y%m%dT%H:%M:%S", current_time);
+ strftime(output, arraysize(output), "%Y%m%dT%H:%M:%S", current_time);
result->AddAttr(kQnStamp, output, 1);
}
}
diff --git a/modules/remote_bitrate_estimator/test/bwe_test.cc b/modules/remote_bitrate_estimator/test/bwe_test.cc
index f2ff768..2f54cb5 100644
--- a/modules/remote_bitrate_estimator/test/bwe_test.cc
+++ b/modules/remote_bitrate_estimator/test/bwe_test.cc
@@ -12,6 +12,7 @@
#include <sstream>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/include/module_common_types.h"
@@ -662,7 +663,7 @@
void BweTest::RunRoundTripTimeFairness(BandwidthEstimatorType bwe_type) {
const int kAllFlowIds[] = {0, 1, 2, 3, 4}; // Five RMCAT flows.
const int64_t kAllOneWayDelayMs[] = {10, 25, 50, 100, 150};
- const size_t kNumFlows = ARRAY_SIZE(kAllFlowIds);
+ const size_t kNumFlows = arraysize(kAllFlowIds);
rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumFlows];
rtc::scoped_ptr<VideoSender> senders[kNumFlows];
rtc::scoped_ptr<MetricRecorder> metric_recorders[kNumFlows];
@@ -774,10 +775,10 @@
const int kAllTcpFlowIds[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
assert(tcp_starting_times_ms.size() == tcp_file_sizes_bytes.size() &&
- tcp_starting_times_ms.size() == ARRAY_SIZE(kAllTcpFlowIds));
+ tcp_starting_times_ms.size() == arraysize(kAllTcpFlowIds));
- const size_t kNumRmcatFlows = ARRAY_SIZE(kAllRmcatFlowIds);
- const size_t kNumTotalFlows = kNumRmcatFlows + ARRAY_SIZE(kAllTcpFlowIds);
+ const size_t kNumRmcatFlows = arraysize(kAllRmcatFlowIds);
+ const size_t kNumTotalFlows = kNumRmcatFlows + arraysize(kAllTcpFlowIds);
rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumRmcatFlows];
rtc::scoped_ptr<PacketSender> senders[kNumTotalFlows];
@@ -869,7 +870,7 @@
// During the test, one of the flows is paused and later resumed.
void BweTest::RunPauseResumeFlows(BandwidthEstimatorType bwe_type) {
const int kAllFlowIds[] = {0, 1, 2}; // Three RMCAT flows.
- const size_t kNumFlows = ARRAY_SIZE(kAllFlowIds);
+ const size_t kNumFlows = arraysize(kAllFlowIds);
rtc::scoped_ptr<AdaptiveVideoSource> sources[kNumFlows];
rtc::scoped_ptr<VideoSender> senders[kNumFlows];
diff --git a/modules/remote_bitrate_estimator/test/bwe_unittest.cc b/modules/remote_bitrate_estimator/test/bwe_unittest.cc
index 6b3ce48..6245ccd 100644
--- a/modules/remote_bitrate_estimator/test/bwe_unittest.cc
+++ b/modules/remote_bitrate_estimator/test/bwe_unittest.cc
@@ -13,6 +13,7 @@
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/base/arraysize.h"
namespace webrtc {
namespace testing {
@@ -241,7 +242,7 @@
// Missing the element 5.
const uint16_t kSequenceNumbers[] = {1, 2, 3, 4, 6, 7, 8};
- const int kNumPackets = ARRAY_SIZE(kSequenceNumbers);
+ const int kNumPackets = arraysize(kSequenceNumbers);
// Insert each sequence number twice.
for (int i = 0; i < 2; ++i) {
diff --git a/modules/remote_bitrate_estimator/test/estimators/nada.cc b/modules/remote_bitrate_estimator/test/estimators/nada.cc
index 171d196..6166ff8 100644
--- a/modules/remote_bitrate_estimator/test/estimators/nada.cc
+++ b/modules/remote_bitrate_estimator/test/estimators/nada.cc
@@ -18,6 +18,7 @@
#include <algorithm>
#include <vector>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/modules/remote_bitrate_estimator/test/estimators/nada.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h"
@@ -63,7 +64,7 @@
}
delay_signal_ms_ = delay_ms - baseline_delay_ms_; // Refered as d_n.
- const int kMedian = ARRAY_SIZE(last_delays_ms_);
+ const int kMedian = arraysize(last_delays_ms_);
last_delays_ms_[(last_delays_index_++) % kMedian] = delay_signal_ms_;
int size = std::min(last_delays_index_, kMedian);
diff --git a/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc b/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc
index a0f56b7..51afae1 100644
--- a/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc
+++ b/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc
@@ -13,6 +13,7 @@
#include <algorithm>
#include <numeric>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h"
@@ -357,7 +358,7 @@
// Baseline delay will be 50 ms.
// Delay signals should be: [0 10 20 30 40 50 60 70] ms.
const int64_t kMedianFilteredDelaysMs[] = {0, 5, 10, 15, 20, 30, 40, 50};
- const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs);
+ const int kNumPackets = arraysize(kMedianFilteredDelaysMs);
const float kAlpha = 0.1f; // Used for exponential smoothing.
int64_t exp_smoothed_delays_ms[kNumPackets];
@@ -426,7 +427,7 @@
// Delay signals should be: [0 200 400 600 800 1000 1200 1400] ms.
const int64_t kMedianFilteredDelaysMs[] = {
0, 100, 200, 300, 400, 600, 800, 1000};
- const int kNumPackets = ARRAY_SIZE(kMedianFilteredDelaysMs);
+ const int kNumPackets = arraysize(kMedianFilteredDelaysMs);
const float kAlpha = 0.1f; // Used for exponential smoothing.
int64_t exp_smoothed_delays_ms[kNumPackets];
@@ -480,7 +481,7 @@
TEST_F(FilterTest, ExponentialSmoothingInitialPertubation) {
const int64_t kSignal[] = {90000, 0, 0, 0, 0, 0};
- const int kNumElements = ARRAY_SIZE(kSignal);
+ const int kNumElements = arraysize(kSignal);
int64_t exp_smoothed[kNumElements];
ExponentialSmoothingFilter(kSignal, kNumElements, exp_smoothed);
for (int i = 1; i < kNumElements; ++i) {
diff --git a/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc b/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc
index ceadf4c..7a7e3ed 100644
--- a/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc
+++ b/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc
@@ -12,6 +12,7 @@
#include "testing/gtest/include/gtest/gtest.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/bitbuffer.h"
namespace webrtc {
@@ -121,7 +122,7 @@
const uint8_t buffer[] = {0x7A, 0x00, 0x1F, 0xBC, 0xD9, 0x40, 0x50, 0x05,
0xBA, 0x10, 0x00, 0x00, 0x03, 0x00, 0xC0, 0x00,
0x00, 0x2A, 0xE0, 0xF1, 0x83, 0x19, 0x60};
- H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
+ H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
EXPECT_TRUE(parser.Parse());
EXPECT_EQ(1280u, parser.width());
EXPECT_EQ(720u, parser.height());
@@ -133,7 +134,7 @@
const uint8_t buffer[] = {0x7A, 0x00, 0x1E, 0xBC, 0xD9, 0x40, 0xA0, 0x2F,
0xF8, 0x98, 0x40, 0x00, 0x00, 0x03, 0x01, 0x80,
0x00, 0x00, 0x56, 0x83, 0xC5, 0x8B, 0x65, 0x80};
- H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
+ H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
EXPECT_TRUE(parser.Parse());
EXPECT_EQ(640u, parser.width());
EXPECT_EQ(360u, parser.height());
@@ -145,7 +146,7 @@
const uint8_t buffer[] = {0x7A, 0x00, 0x0D, 0xBC, 0xD9, 0x43, 0x43, 0x3E,
0x5E, 0x10, 0x00, 0x00, 0x03, 0x00, 0x60, 0x00,
0x00, 0x15, 0xA0, 0xF1, 0x42, 0x99, 0x60};
- H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
+ H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
EXPECT_TRUE(parser.Parse());
EXPECT_EQ(200u, parser.width());
EXPECT_EQ(400u, parser.height());
@@ -154,7 +155,7 @@
TEST(H264SpsParserTest, TestSyntheticSPSQvgaLandscape) {
uint8_t buffer[kSpsBufferMaxSize] = {0};
GenerateFakeSps(320u, 180u, buffer);
- H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
+ H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
EXPECT_TRUE(parser.Parse());
EXPECT_EQ(320u, parser.width());
EXPECT_EQ(180u, parser.height());
@@ -163,7 +164,7 @@
TEST(H264SpsParserTest, TestSyntheticSPSWeirdResolution) {
uint8_t buffer[kSpsBufferMaxSize] = {0};
GenerateFakeSps(156u, 122u, buffer);
- H264SpsParser parser = H264SpsParser(buffer, ARRAY_SIZE(buffer));
+ H264SpsParser parser = H264SpsParser(buffer, arraysize(buffer));
EXPECT_TRUE(parser.Parse());
EXPECT_EQ(156u, parser.width());
EXPECT_EQ(122u, parser.height());
diff --git a/p2p/base/port_unittest.cc b/p2p/base/port_unittest.cc
index c3e5df6..62ba572 100644
--- a/p2p/base/port_unittest.cc
+++ b/p2p/base/port_unittest.cc
@@ -17,6 +17,7 @@
#include "webrtc/p2p/base/testturnserver.h"
#include "webrtc/p2p/base/transport.h"
#include "webrtc/p2p/base/turnport.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/crc32.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
@@ -2223,7 +2224,7 @@
// Data should be unsendable until the connection is accepted.
char data[] = "abcd";
- int data_size = ARRAY_SIZE(data);
+ int data_size = arraysize(data);
rtc::PacketOptions options;
EXPECT_EQ(SOCKET_ERROR, ch1.conn()->Send(data, data_size, options));
diff --git a/p2p/base/pseudotcp.cc b/p2p/base/pseudotcp.cc
index 5f035ca..6281315 100644
--- a/p2p/base/pseudotcp.cc
+++ b/p2p/base/pseudotcp.cc
@@ -16,6 +16,7 @@
#include <algorithm>
#include <set>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/bytebuffer.h"
#include "webrtc/base/byteorder.h"
@@ -187,7 +188,7 @@
char buffer[256];
size_t len = 0;
for (int i = 0; i < S_NUM_STATS; ++i) {
- len += rtc::sprintfn(buffer, ARRAY_SIZE(buffer), "%s%s:%d",
+ len += rtc::sprintfn(buffer, arraysize(buffer), "%s%s:%d",
(i == 0) ? "" : ",", STAT_NAMES[i], g_stats[i]);
g_stats[i] = 0;
}
diff --git a/p2p/base/stun_unittest.cc b/p2p/base/stun_unittest.cc
index cd4f7e1..1249257 100644
--- a/p2p/base/stun_unittest.cc
+++ b/p2p/base/stun_unittest.cc
@@ -11,6 +11,7 @@
#include <string>
#include "webrtc/p2p/base/stun.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/bytebuffer.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/logging.h"
@@ -515,11 +516,11 @@
STUN_BINDING_REQUEST, STUN_BINDING_INDICATION,
STUN_BINDING_RESPONSE, STUN_BINDING_ERROR_RESPONSE
};
- for (int i = 0; i < ARRAY_SIZE(types); ++i) {
- EXPECT_EQ(i == 0, IsStunRequestType(types[i]));
- EXPECT_EQ(i == 1, IsStunIndicationType(types[i]));
- EXPECT_EQ(i == 2, IsStunSuccessResponseType(types[i]));
- EXPECT_EQ(i == 3, IsStunErrorResponseType(types[i]));
+ for (size_t i = 0; i < arraysize(types); ++i) {
+ EXPECT_EQ(i == 0U, IsStunRequestType(types[i]));
+ EXPECT_EQ(i == 1U, IsStunIndicationType(types[i]));
+ EXPECT_EQ(i == 2U, IsStunSuccessResponseType(types[i]));
+ EXPECT_EQ(i == 3U, IsStunErrorResponseType(types[i]));
EXPECT_EQ(1, types[i] & 0xFEEF);
}
}
diff --git a/p2p/base/transportdescription.cc b/p2p/base/transportdescription.cc
index 52033ec..0dcbac6 100644
--- a/p2p/base/transportdescription.cc
+++ b/p2p/base/transportdescription.cc
@@ -10,6 +10,7 @@
#include "webrtc/p2p/base/transportdescription.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/basicdefs.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/p2p/base/constants.h"
@@ -24,7 +25,7 @@
CONNECTIONROLE_HOLDCONN_STR
};
- for (size_t i = 0; i < ARRAY_SIZE(roles); ++i) {
+ for (size_t i = 0; i < arraysize(roles); ++i) {
if (_stricmp(roles[i], role_str.c_str()) == 0) {
*role = static_cast<ConnectionRole>(CONNECTIONROLE_ACTIVE + i);
return true;
diff --git a/sound/alsasoundsystem.cc b/sound/alsasoundsystem.cc
index 3cc77a9..3f97446 100644
--- a/sound/alsasoundsystem.cc
+++ b/sound/alsasoundsystem.cc
@@ -11,15 +11,17 @@
#include "webrtc/sound/alsasoundsystem.h"
#include <algorithm>
-#include "webrtc/sound/sounddevicelocator.h"
-#include "webrtc/sound/soundinputstreaminterface.h"
-#include "webrtc/sound/soundoutputstreaminterface.h"
+
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/scoped_ptr.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/base/worker.h"
+#include "webrtc/sound/sounddevicelocator.h"
+#include "webrtc/sound/soundinputstreaminterface.h"
+#include "webrtc/sound/soundoutputstreaminterface.h"
namespace rtc {
@@ -606,8 +608,6 @@
}
inline size_t AlsaSoundSystem::FrameSize(const OpenParams ¶ms) {
- ASSERT(static_cast<int>(params.format) <
- ARRAY_SIZE(kCricketFormatToSampleSizeTable));
return kCricketFormatToSampleSizeTable[params.format] * params.channels;
}
@@ -662,8 +662,7 @@
latency = std::max(latency, kMinimumLatencyUsecs);
}
- ASSERT(static_cast<int>(params.format) <
- ARRAY_SIZE(kCricketFormatToAlsaFormatTable));
+ ASSERT(params.format < arraysize(kCricketFormatToAlsaFormatTable));
err = symbol_table_.snd_pcm_set_params()(
handle,
diff --git a/sound/automaticallychosensoundsystem_unittest.cc b/sound/automaticallychosensoundsystem_unittest.cc
index 5cfd7c6..318385c 100644
--- a/sound/automaticallychosensoundsystem_unittest.cc
+++ b/sound/automaticallychosensoundsystem_unittest.cc
@@ -9,8 +9,10 @@
*/
#include "webrtc/sound/automaticallychosensoundsystem.h"
-#include "webrtc/sound/nullsoundsystem.h"
+
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/gunit.h"
+#include "webrtc/sound/nullsoundsystem.h"
namespace rtc {
@@ -112,7 +114,7 @@
TEST(AutomaticallyChosenSoundSystem, SingleSystemFailing) {
AutomaticallyChosenSoundSystem<
kSingleSystemFailingCreators,
- ARRAY_SIZE(kSingleSystemFailingCreators)> sound_system;
+ arraysize(kSingleSystemFailingCreators)> sound_system;
EXPECT_FALSE(sound_system.Init());
}
@@ -123,7 +125,7 @@
TEST(AutomaticallyChosenSoundSystem, SingleSystemSucceeding) {
AutomaticallyChosenSoundSystem<
kSingleSystemSucceedingCreators,
- ARRAY_SIZE(kSingleSystemSucceedingCreators)> sound_system;
+ arraysize(kSingleSystemSucceedingCreators)> sound_system;
EXPECT_TRUE(sound_system.Init());
}
@@ -136,7 +138,7 @@
TEST(AutomaticallyChosenSoundSystem, FailedFirstSystemResultsInUsingSecond) {
AutomaticallyChosenSoundSystem<
kFailedFirstSystemResultsInUsingSecondCreators,
- ARRAY_SIZE(kFailedFirstSystemResultsInUsingSecondCreators)> sound_system;
+ arraysize(kFailedFirstSystemResultsInUsingSecondCreators)> sound_system;
EXPECT_TRUE(sound_system.Init());
}
@@ -148,7 +150,7 @@
TEST(AutomaticallyChosenSoundSystem, EarlierEntriesHavePriority) {
AutomaticallyChosenSoundSystem<
kEarlierEntriesHavePriorityCreators,
- ARRAY_SIZE(kEarlierEntriesHavePriorityCreators)> sound_system;
+ arraysize(kEarlierEntriesHavePriorityCreators)> sound_system;
InitCheckingSoundSystem1::created_ = false;
InitCheckingSoundSystem2::created_ = false;
EXPECT_TRUE(sound_system.Init());
@@ -169,7 +171,7 @@
TEST(AutomaticallyChosenSoundSystem, ManySoundSystems) {
AutomaticallyChosenSoundSystem<
kManySoundSystemsCreators,
- ARRAY_SIZE(kManySoundSystemsCreators)> sound_system;
+ arraysize(kManySoundSystemsCreators)> sound_system;
EXPECT_TRUE(sound_system.Init());
}
@@ -182,7 +184,7 @@
TEST(AutomaticallyChosenSoundSystem, DeletesAllCreatedSoundSystems) {
typedef AutomaticallyChosenSoundSystem<
kDeletesAllCreatedSoundSystemsCreators,
- ARRAY_SIZE(kDeletesAllCreatedSoundSystemsCreators)> TestSoundSystem;
+ arraysize(kDeletesAllCreatedSoundSystemsCreators)> TestSoundSystem;
TestSoundSystem *sound_system = new TestSoundSystem();
DeletionCheckingSoundSystem1::deleted_ = false;
DeletionCheckingSoundSystem2::deleted_ = false;
diff --git a/sound/linuxsoundsystem.h b/sound/linuxsoundsystem.h
index 0016f8a..56721a1 100644
--- a/sound/linuxsoundsystem.h
+++ b/sound/linuxsoundsystem.h
@@ -11,6 +11,7 @@
#ifndef WEBRTC_SOUND_LINUXSOUNDSYSTEM_H_
#define WEBRTC_SOUND_LINUXSOUNDSYSTEM_H_
+#include "webrtc/base/arraysize.h"
#include "webrtc/sound/automaticallychosensoundsystem.h"
namespace rtc {
@@ -34,7 +35,7 @@
// initializes then we choose that. Otherwise we choose ALSA.
typedef AutomaticallyChosenSoundSystem<
kLinuxSoundSystemCreators,
- ARRAY_SIZE(kLinuxSoundSystemCreators)> LinuxSoundSystem;
+ arraysize(kLinuxSoundSystemCreators)> LinuxSoundSystem;
} // namespace rtc
diff --git a/sound/pulseaudiosoundsystem.cc b/sound/pulseaudiosoundsystem.cc
index b44a1df..b1845f5 100644
--- a/sound/pulseaudiosoundsystem.cc
+++ b/sound/pulseaudiosoundsystem.cc
@@ -13,14 +13,16 @@
#ifdef HAVE_LIBPULSE
#include <algorithm>
-#include "webrtc/sound/sounddevicelocator.h"
-#include "webrtc/sound/soundinputstreaminterface.h"
-#include "webrtc/sound/soundoutputstreaminterface.h"
+
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/fileutils.h" // for GetApplicationName()
#include "webrtc/base/logging.h"
#include "webrtc/base/timeutils.h"
#include "webrtc/base/worker.h"
+#include "webrtc/sound/sounddevicelocator.h"
+#include "webrtc/sound/soundinputstreaminterface.h"
+#include "webrtc/sound/soundoutputstreaminterface.h"
namespace rtc {
@@ -1373,7 +1375,7 @@
StreamInterface *stream_interface = NULL;
- ASSERT(params.format < ARRAY_SIZE(kCricketFormatToPulseFormatTable));
+ ASSERT(params.format < arraysize(kCricketFormatToPulseFormatTable));
pa_sample_spec spec;
spec.format = kCricketFormatToPulseFormatTable[params.format];