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-Commit-Position: refs/heads/master@{#10594}
diff --git a/talk/app/webrtc/jsepsessiondescription.cc b/talk/app/webrtc/jsepsessiondescription.cc
index 24bd9d4..226432d 100644
--- a/talk/app/webrtc/jsepsessiondescription.cc
+++ b/talk/app/webrtc/jsepsessiondescription.cc
@@ -29,6 +29,7 @@
#include "talk/app/webrtc/webrtcsdp.h"
#include "talk/session/media/mediasession.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/stringencode.h"
using rtc::scoped_ptr;
@@ -44,7 +45,7 @@
static bool IsTypeSupported(const std::string& type) {
bool type_supported = false;
- for (size_t i = 0; i < ARRAY_SIZE(kSupportedTypes); ++i) {
+ for (size_t i = 0; i < arraysize(kSupportedTypes); ++i) {
if (kSupportedTypes[i] == type) {
type_supported = true;
break;
diff --git a/talk/app/webrtc/peerconnection.cc b/talk/app/webrtc/peerconnection.cc
index 0d519b2..bc7cb36 100644
--- a/talk/app/webrtc/peerconnection.cc
+++ b/talk/app/webrtc/peerconnection.cc
@@ -46,11 +46,12 @@
#include "talk/app/webrtc/videosource.h"
#include "talk/app/webrtc/videotrack.h"
#include "talk/media/sctp/sctpdataengine.h"
-#include "webrtc/p2p/client/basicportallocator.h"
#include "talk/session/media/channelmanager.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/stringencode.h"
#include "webrtc/base/stringutils.h"
+#include "webrtc/p2p/client/basicportallocator.h"
#include "webrtc/system_wrappers/include/field_trial.h"
namespace {
@@ -95,7 +96,7 @@
TURNS, // Indicates a TURN server used with a TLS session.
INVALID, // Unknown.
};
-static_assert(INVALID == ARRAY_SIZE(kValidIceServiceTypes),
+static_assert(INVALID == arraysize(kValidIceServiceTypes),
"kValidIceServiceTypes must have as many strings as ServiceType "
"has values.");
@@ -156,7 +157,7 @@
return false;
}
*service_type = INVALID;
- for (size_t i = 0; i < ARRAY_SIZE(kValidIceServiceTypes); ++i) {
+ for (size_t i = 0; i < arraysize(kValidIceServiceTypes); ++i) {
if (in_str.compare(0, colonpos, kValidIceServiceTypes[i]) == 0) {
*service_type = static_cast<ServiceType>(i);
break;
diff --git a/talk/app/webrtc/videosource.cc b/talk/app/webrtc/videosource.cc
index 7331e0e..4e27b43 100644
--- a/talk/app/webrtc/videosource.cc
+++ b/talk/app/webrtc/videosource.cc
@@ -32,6 +32,7 @@
#include "talk/app/webrtc/mediaconstraintsinterface.h"
#include "talk/session/media/channelmanager.h"
+#include "webrtc/base/arraysize.h"
using cricket::CaptureState;
using webrtc::MediaConstraintsInterface;
@@ -369,7 +370,7 @@
} else {
// The VideoCapturer implementation doesn't support capability
// enumeration. We need to guess what the camera supports.
- for (int i = 0; i < ARRAY_SIZE(kVideoFormats); ++i) {
+ for (int i = 0; i < arraysize(kVideoFormats); ++i) {
formats.push_back(cricket::VideoFormat(kVideoFormats[i]));
}
}
diff --git a/talk/app/webrtc/webrtcsdp.cc b/talk/app/webrtc/webrtcsdp.cc
index 3fa9a7d..fceaaf4 100644
--- a/talk/app/webrtc/webrtcsdp.cc
+++ b/talk/app/webrtc/webrtcsdp.cc
@@ -45,6 +45,7 @@
#include "webrtc/p2p/base/constants.h"
#include "webrtc/p2p/base/port.h"
#include "talk/session/media/mediasession.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/messagedigest.h"
@@ -1525,7 +1526,7 @@
kCodecParamMaxAverageBitrate, kCodecParamMaxPlaybackRate,
kCodecParamAssociatedPayloadType
};
- for (size_t i = 0; i < ARRAY_SIZE(kFmtpParams); ++i) {
+ for (size_t i = 0; i < arraysize(kFmtpParams); ++i) {
if (_stricmp(name.c_str(), kFmtpParams[i]) == 0) {
return true;
}
@@ -2082,7 +2083,7 @@
int payload_type = *it;
if (!media_desc->HasCodec(payload_type) &&
payload_type >= 0 &&
- payload_type < ARRAY_SIZE(kStaticPayloadAudioCodecs)) {
+ payload_type < arraysize(kStaticPayloadAudioCodecs)) {
std::string encoding_name = kStaticPayloadAudioCodecs[payload_type].name;
int clock_rate = kStaticPayloadAudioCodecs[payload_type].clockrate;
int channels = kStaticPayloadAudioCodecs[payload_type].channels;
diff --git a/talk/media/base/capturemanager_unittest.cc b/talk/media/base/capturemanager_unittest.cc
index e990342..84086ab 100644
--- a/talk/media/base/capturemanager_unittest.cc
+++ b/talk/media/base/capturemanager_unittest.cc
@@ -29,6 +29,7 @@
#include "talk/media/base/fakevideocapturer.h"
#include "talk/media/base/fakevideorenderer.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/sigslot.h"
@@ -57,7 +58,7 @@
}
void PopulateSupportedFormats() {
std::vector<cricket::VideoFormat> formats;
- for (int i = 0; i < ARRAY_SIZE(kCameraFormats); ++i) {
+ for (int i = 0; i < arraysize(kCameraFormats); ++i) {
formats.push_back(cricket::VideoFormat(kCameraFormats[i]));
}
video_capturer_.ResetSupportedFormats(formats);
diff --git a/talk/media/base/streamparams_unittest.cc b/talk/media/base/streamparams_unittest.cc
index a9e1ce3..a016473 100644
--- a/talk/media/base/streamparams_unittest.cc
+++ b/talk/media/base/streamparams_unittest.cc
@@ -27,6 +27,7 @@
#include "talk/media/base/streamparams.h"
#include "talk/media/base/testutils.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/gunit.h"
static const uint32_t kSsrcs1[] = {1};
@@ -54,8 +55,8 @@
cricket::SsrcGroup("abc", MAKE_VECTOR(kSsrcs2)),
};
- for (size_t i = 0; i < ARRAY_SIZE(ssrc_groups); ++i) {
- for (size_t j = 0; j < ARRAY_SIZE(ssrc_groups); ++j) {
+ for (size_t i = 0; i < arraysize(ssrc_groups); ++i) {
+ for (size_t j = 0; j < arraysize(ssrc_groups); ++j) {
EXPECT_EQ((ssrc_groups[i] == ssrc_groups[j]), (i == j));
EXPECT_EQ((ssrc_groups[i] != ssrc_groups[j]), (i != j));
}
@@ -92,7 +93,7 @@
TEST(StreamParams, HasSsrcGroup) {
cricket::StreamParams sp =
- CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, ARRAY_SIZE(kSsrcs2));
+ CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2));
EXPECT_EQ(2U, sp.ssrcs.size());
EXPECT_EQ(kSsrcs2[0], sp.first_ssrc());
EXPECT_TRUE(sp.has_ssrcs());
@@ -107,7 +108,7 @@
TEST(StreamParams, GetSsrcGroup) {
cricket::StreamParams sp =
- CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, ARRAY_SIZE(kSsrcs2));
+ CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2));
EXPECT_EQ(NULL, sp.get_ssrc_group("xyz"));
EXPECT_EQ(&sp.ssrc_groups[0], sp.get_ssrc_group("XYZ"));
}
@@ -116,17 +117,17 @@
cricket::StreamParams l1 = cricket::StreamParams::CreateLegacy(1);
cricket::StreamParams l2 = cricket::StreamParams::CreateLegacy(2);
cricket::StreamParams sg1 =
- CreateStreamParamsWithSsrcGroup("ABC", kSsrcs1, ARRAY_SIZE(kSsrcs1));
+ CreateStreamParamsWithSsrcGroup("ABC", kSsrcs1, arraysize(kSsrcs1));
cricket::StreamParams sg2 =
- CreateStreamParamsWithSsrcGroup("ABC", kSsrcs2, ARRAY_SIZE(kSsrcs2));
+ CreateStreamParamsWithSsrcGroup("ABC", kSsrcs2, arraysize(kSsrcs2));
cricket::StreamParams sg3 =
- CreateStreamParamsWithSsrcGroup("Abc", kSsrcs2, ARRAY_SIZE(kSsrcs2));
+ CreateStreamParamsWithSsrcGroup("Abc", kSsrcs2, arraysize(kSsrcs2));
cricket::StreamParams sg4 =
- CreateStreamParamsWithSsrcGroup("abc", kSsrcs2, ARRAY_SIZE(kSsrcs2));
+ CreateStreamParamsWithSsrcGroup("abc", kSsrcs2, arraysize(kSsrcs2));
cricket::StreamParams sps[] = {l1, l2, sg1, sg2, sg3, sg4};
- for (size_t i = 0; i < ARRAY_SIZE(sps); ++i) {
- for (size_t j = 0; j < ARRAY_SIZE(sps); ++j) {
+ for (size_t i = 0; i < arraysize(sps); ++i) {
+ for (size_t j = 0; j < arraysize(sps); ++j) {
EXPECT_EQ((sps[i] == sps[j]), (i == j));
EXPECT_EQ((sps[i] != sps[j]), (i != j));
}
@@ -195,7 +196,7 @@
TEST(StreamParams, ToString) {
cricket::StreamParams sp =
- CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, ARRAY_SIZE(kSsrcs2));
+ CreateStreamParamsWithSsrcGroup("XYZ", kSsrcs2, arraysize(kSsrcs2));
EXPECT_STREQ("{ssrcs:[1,2];ssrc_groups:{semantics:XYZ;ssrcs:[1,2]};}",
sp.ToString().c_str());
}
diff --git a/talk/media/base/testutils.cc b/talk/media/base/testutils.cc
index 3b1fcf0..49a78e6 100644
--- a/talk/media/base/testutils.cc
+++ b/talk/media/base/testutils.cc
@@ -132,8 +132,8 @@
};
size_t RtpTestUtility::GetTestPacketCount() {
- return std::min(ARRAY_SIZE(kTestRawRtpPackets),
- ARRAY_SIZE(kTestRawRtcpPackets));
+ return std::min(arraysize(kTestRawRtpPackets),
+ arraysize(kTestRawRtcpPackets));
}
bool RtpTestUtility::WriteTestPackets(size_t count,
diff --git a/talk/media/base/testutils.h b/talk/media/base/testutils.h
index cb4146d..20c0d62 100644
--- a/talk/media/base/testutils.h
+++ b/talk/media/base/testutils.h
@@ -35,6 +35,7 @@
#include "talk/media/base/mediachannel.h"
#include "talk/media/base/videocapturer.h"
#include "talk/media/base/videocommon.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/window.h"
@@ -54,7 +55,7 @@
template <class T> inline std::vector<T> MakeVector(const T a[], size_t s) {
return std::vector<T>(a, a + s);
}
-#define MAKE_VECTOR(a) cricket::MakeVector(a, ARRAY_SIZE(a))
+#define MAKE_VECTOR(a) cricket::MakeVector(a, arraysize(a))
struct RtpDumpPacket;
class RtpDumpWriter;
diff --git a/talk/media/base/videocommon.cc b/talk/media/base/videocommon.cc
index 7b6aac2..a4e9815 100644
--- a/talk/media/base/videocommon.cc
+++ b/talk/media/base/videocommon.cc
@@ -31,6 +31,7 @@
#include <math.h>
#include <sstream>
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
namespace cricket {
@@ -58,7 +59,7 @@
};
uint32_t CanonicalFourCC(uint32_t fourcc) {
- for (int i = 0; i < ARRAY_SIZE(kFourCCAliases); ++i) {
+ for (int i = 0; i < arraysize(kFourCCAliases); ++i) {
if (kFourCCAliases[i].alias == fourcc) {
return kFourCCAliases[i].canonical;
}
@@ -75,7 +76,7 @@
1.f / 16.f // 1/16 scale.
};
-static const int kNumScaleFactors = ARRAY_SIZE(kScaleFactors);
+static const int kNumScaleFactors = arraysize(kScaleFactors);
// Finds the scale factor that, when applied to width and height, produces
// fewer than num_pixels.
diff --git a/talk/media/base/videoframe.cc b/talk/media/base/videoframe.cc
index 2b604b0..3e4d60a 100644
--- a/talk/media/base/videoframe.cc
+++ b/talk/media/base/videoframe.cc
@@ -33,6 +33,7 @@
#include "libyuv/planar_functions.h"
#include "libyuv/scale.h"
#include "talk/media/base/videocommon.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/logging.h"
@@ -318,7 +319,7 @@
}
// TODO(fbarchard): Make function to dump information about frames.
uint8_t four_samples[4] = {0, 0, 0, 0};
- for (size_t i = 0; i < ARRAY_SIZE(four_samples) && i < sample_size; ++i) {
+ for (size_t i = 0; i < arraysize(four_samples) && i < sample_size; ++i) {
four_samples[i] = sample[i];
}
if (sample_size < expected_size) {
diff --git a/talk/media/devices/devicemanager_unittest.cc b/talk/media/devices/devicemanager_unittest.cc
index f259c7d..ead0184 100644
--- a/talk/media/devices/devicemanager_unittest.cc
+++ b/talk/media/devices/devicemanager_unittest.cc
@@ -39,6 +39,7 @@
#include "talk/media/base/videocapturerfactory.h"
#include "talk/media/devices/filevideocapturer.h"
#include "talk/media/devices/v4llookup.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/logging.h"
@@ -269,19 +270,19 @@
"device5",
};
std::vector<Device> devices;
- for (int i = 0; i < ARRAY_SIZE(kTotalDevicesName); ++i) {
+ for (int i = 0; i < arraysize(kTotalDevicesName); ++i) {
devices.push_back(Device(kTotalDevicesName[i], i));
}
EXPECT_TRUE(CompareDeviceList(devices, kTotalDevicesName,
- ARRAY_SIZE(kTotalDevicesName)));
+ arraysize(kTotalDevicesName)));
// Return false if given NULL as the exclusion list.
EXPECT_TRUE(DeviceManager::FilterDevices(&devices, NULL));
// The devices should not change.
EXPECT_TRUE(CompareDeviceList(devices, kTotalDevicesName,
- ARRAY_SIZE(kTotalDevicesName)));
+ arraysize(kTotalDevicesName)));
EXPECT_TRUE(DeviceManager::FilterDevices(&devices, kFilteredDevicesName));
EXPECT_TRUE(CompareDeviceList(devices, kDevicesName,
- ARRAY_SIZE(kDevicesName)));
+ arraysize(kDevicesName)));
}
#ifdef LINUX
diff --git a/talk/media/devices/win32devicemanager.cc b/talk/media/devices/win32devicemanager.cc
index 1b9e9d8..f34e3c4 100644
--- a/talk/media/devices/win32devicemanager.cc
+++ b/talk/media/devices/win32devicemanager.cc
@@ -48,6 +48,7 @@
} }, 4
};
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/stringutils.h"
#include "webrtc/base/thread.h"
@@ -148,7 +149,7 @@
*device = devices[0];
for (size_t i = 0; i < devices.size(); ++i) {
if (strnicmp(devices[i].id.c_str(), kUsbDevicePathPrefix,
- ARRAY_SIZE(kUsbDevicePathPrefix) - 1) == 0) {
+ arraysize(kUsbDevicePathPrefix) - 1) == 0) {
*device = devices[i];
break;
}
diff --git a/talk/media/sctp/sctpdataengine.cc b/talk/media/sctp/sctpdataengine.cc
index c88882d..94f242a 100644
--- a/talk/media/sctp/sctpdataengine.cc
+++ b/talk/media/sctp/sctpdataengine.cc
@@ -36,6 +36,7 @@
#include "talk/media/base/constants.h"
#include "talk/media/base/streamparams.h"
#include "usrsctplib/usrsctp.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/buffer.h"
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
@@ -76,7 +77,7 @@
MAKEFLAG(SCTP_STREAM_CHANGE_DENIED)
};
#undef MAKEFLAG
- for (int i = 0; i < ARRAY_SIZE(flaginfo); ++i) {
+ for (int i = 0; i < arraysize(flaginfo); ++i) {
if (flags & flaginfo[i].value) {
if (!first) result << " | ";
result << flaginfo[i].name;
@@ -473,7 +474,7 @@
struct sctp_event event = {0};
event.se_assoc_id = SCTP_ALL_ASSOC;
event.se_on = 1;
- for (size_t i = 0; i < ARRAY_SIZE(event_types); i++) {
+ for (size_t i = 0; i < arraysize(event_types); i++) {
event.se_type = event_types[i];
if (usrsctp_setsockopt(sock_, IPPROTO_SCTP, SCTP_EVENT, &event,
sizeof(event)) < 0) {
diff --git a/talk/media/webrtc/simulcast.cc b/talk/media/webrtc/simulcast.cc
index f55d960..b67a363 100755
--- a/talk/media/webrtc/simulcast.cc
+++ b/talk/media/webrtc/simulcast.cc
@@ -29,9 +29,11 @@
#include "talk/media/base/streamparams.h"
#include "talk/media/webrtc/simulcast.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/common.h"
#include "webrtc/base/logging.h"
#include "webrtc/system_wrappers/include/field_trial.h"
+
namespace cricket {
struct SimulcastFormat {
@@ -93,7 +95,7 @@
int FindSimulcastFormatIndex(int width, int height) {
MaybeExchangeWidthHeight(&width, &height);
- for (int i = 0; i < ARRAY_SIZE(kSimulcastFormats); ++i) {
+ for (int i = 0; i < arraysize(kSimulcastFormats); ++i) {
if (width >= kSimulcastFormats[i].width &&
height >= kSimulcastFormats[i].height) {
return i;
@@ -105,7 +107,7 @@
int FindSimulcastFormatIndex(int width, int height, size_t max_layers) {
MaybeExchangeWidthHeight(&width, &height);
- for (int i = 0; i < ARRAY_SIZE(kSimulcastFormats); ++i) {
+ for (int i = 0; i < arraysize(kSimulcastFormats); ++i) {
if (width >= kSimulcastFormats[i].width &&
height >= kSimulcastFormats[i].height &&
max_layers == kSimulcastFormats[i].max_layers) {
diff --git a/talk/media/webrtc/webrtcmediaengine.cc b/talk/media/webrtc/webrtcmediaengine.cc
index af202bd..e1d4ac2 100644
--- a/talk/media/webrtc/webrtcmediaengine.cc
+++ b/talk/media/webrtc/webrtcmediaengine.cc
@@ -28,6 +28,7 @@
#include "talk/media/webrtc/webrtcmediaengine.h"
#include "talk/media/webrtc/webrtcvideoengine2.h"
#include "talk/media/webrtc/webrtcvoiceengine.h"
+#include "webrtc/base/arraysize.h"
namespace cricket {
@@ -72,8 +73,7 @@
kRtpTransportSequenceNumberHeaderExtension,
kRtpAbsoluteSenderTimeHeaderExtension, kRtpTimestampOffsetHeaderExtension};
-const size_t kBweExtensionPrioritiesLength =
- ARRAY_SIZE(kBweExtensionPriorities);
+const size_t kBweExtensionPrioritiesLength = arraysize(kBweExtensionPriorities);
int GetPriority(const RtpHeaderExtension& extension,
const char* extension_prios[],
diff --git a/talk/media/webrtc/webrtcvideocapturer.cc b/talk/media/webrtc/webrtcvideocapturer.cc
index 7d72128..519b58a 100644
--- a/talk/media/webrtc/webrtcvideocapturer.cc
+++ b/talk/media/webrtc/webrtcvideocapturer.cc
@@ -34,6 +34,7 @@
#ifdef HAVE_WEBRTC_VIDEO
#include "talk/media/webrtc/webrtcvideoframe.h"
#include "talk/media/webrtc/webrtcvideoframefactory.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/checks.h"
#include "webrtc/base/criticalsection.h"
@@ -83,7 +84,7 @@
static bool CapabilityToFormat(const webrtc::VideoCaptureCapability& cap,
VideoFormat* format) {
uint32_t fourcc = 0;
- for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) {
+ for (size_t i = 0; i < arraysize(kSupportedFourCCs); ++i) {
if (kSupportedFourCCs[i].webrtc_type == cap.rawType) {
fourcc = kSupportedFourCCs[i].fourcc;
break;
@@ -103,7 +104,7 @@
static bool FormatToCapability(const VideoFormat& format,
webrtc::VideoCaptureCapability* cap) {
webrtc::RawVideoType webrtc_type = webrtc::kVideoUnknown;
- for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) {
+ for (size_t i = 0; i < arraysize(kSupportedFourCCs); ++i) {
if (kSupportedFourCCs[i].fourcc == format.fourcc) {
webrtc_type = kSupportedFourCCs[i].webrtc_type;
break;
@@ -171,8 +172,8 @@
bool found = false;
for (int index = 0; index < num_cams; ++index) {
char vcm_name[256];
- if (info->GetDeviceName(index, vcm_name, ARRAY_SIZE(vcm_name),
- vcm_id, ARRAY_SIZE(vcm_id)) != -1) {
+ if (info->GetDeviceName(index, vcm_name, arraysize(vcm_name), vcm_id,
+ arraysize(vcm_id)) != -1) {
if (device.name == reinterpret_cast<char*>(vcm_name)) {
found = true;
break;
@@ -361,7 +362,7 @@
}
fourccs->clear();
- for (size_t i = 0; i < ARRAY_SIZE(kSupportedFourCCs); ++i) {
+ for (size_t i = 0; i < arraysize(kSupportedFourCCs); ++i) {
fourccs->push_back(kSupportedFourCCs[i].fourcc);
}
return true;
diff --git a/talk/media/webrtc/webrtcvoiceengine.cc b/talk/media/webrtc/webrtcvoiceengine.cc
index ba6408f..a7e1a43 100644
--- a/talk/media/webrtc/webrtcvoiceengine.cc
+++ b/talk/media/webrtc/webrtcvoiceengine.cc
@@ -43,6 +43,7 @@
#include "talk/media/base/constants.h"
#include "talk/media/base/streamparams.h"
#include "talk/media/webrtc/webrtcvoe.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/base64.h"
#include "webrtc/base/byteorder.h"
#include "webrtc/base/common.h"
@@ -212,7 +213,7 @@
}
bool IsCodecMultiRate(const webrtc::CodecInst& codec) {
- for (size_t i = 0; i < ARRAY_SIZE(kCodecPrefs); ++i) {
+ for (size_t i = 0; i < arraysize(kCodecPrefs); ++i) {
if (IsCodec(codec, kCodecPrefs[i].name) &&
kCodecPrefs[i].clockrate == codec.plfreq) {
return kCodecPrefs[i].is_multi_rate;
@@ -455,7 +456,7 @@
}
const CodecPref* pref = NULL;
- for (size_t j = 0; j < ARRAY_SIZE(kCodecPrefs); ++j) {
+ for (size_t j = 0; j < arraysize(kCodecPrefs); ++j) {
if (IsCodec(voe_codec, kCodecPrefs[j].name) &&
kCodecPrefs[j].clockrate == voe_codec.plfreq &&
kCodecPrefs[j].channels == voe_codec.channels) {
@@ -467,9 +468,10 @@
if (pref) {
// Use the payload type that we've configured in our pref table;
// use the offset in our pref table to determine the sort order.
- AudioCodec codec(pref->payload_type, voe_codec.plname, voe_codec.plfreq,
- voe_codec.rate, voe_codec.channels,
- ARRAY_SIZE(kCodecPrefs) - (pref - kCodecPrefs));
+ AudioCodec codec(
+ pref->payload_type, voe_codec.plname, voe_codec.plfreq,
+ voe_codec.rate, voe_codec.channels,
+ static_cast<int>(arraysize(kCodecPrefs)) - (pref - kCodecPrefs));
LOG(LS_INFO) << ToString(codec);
if (IsCodec(codec, kIsacCodecName)) {
// Indicate auto-bitrate in signaling.
diff --git a/talk/media/webrtc/webrtcvoiceengine_unittest.cc b/talk/media/webrtc/webrtcvoiceengine_unittest.cc
index 3f63fd7..0e2781b 100644
--- a/talk/media/webrtc/webrtcvoiceengine_unittest.cc
+++ b/talk/media/webrtc/webrtcvoiceengine_unittest.cc
@@ -25,6 +25,7 @@
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/byteorder.h"
#include "webrtc/base/gunit.h"
#include "webrtc/call.h"
@@ -91,7 +92,7 @@
public:
WebRtcVoiceEngineTestFake()
: call_(webrtc::Call::Config()),
- voe_(kAudioCodecs, ARRAY_SIZE(kAudioCodecs)),
+ voe_(kAudioCodecs, arraysize(kAudioCodecs)),
trace_wrapper_(new FakeVoETraceWrapper()),
engine_(new FakeVoEWrapper(&voe_), trace_wrapper_),
channel_(nullptr) {
@@ -493,14 +494,13 @@
cricket::StreamParams::CreateLegacy(kSsrc1)));
int channel_num = voe_.GetLastChannel();
webrtc::CodecInst gcodec;
- rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
+ rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
gcodec.plfreq = 16000;
gcodec.channels = 1;
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
EXPECT_EQ(106, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
- rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname),
- "telephone-event");
+ rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event");
gcodec.plfreq = 8000;
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num, gcodec));
EXPECT_EQ(126, gcodec.pltype);
@@ -607,14 +607,13 @@
cricket::StreamParams::CreateLegacy(kSsrc1)));
int channel_num2 = voe_.GetLastChannel();
webrtc::CodecInst gcodec;
- rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
+ rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
gcodec.plfreq = 16000;
gcodec.channels = 1;
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
EXPECT_EQ(106, gcodec.pltype);
EXPECT_STREQ("ISAC", gcodec.plname);
- rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname),
- "telephone-event");
+ rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "telephone-event");
gcodec.plfreq = 8000;
gcodec.channels = 1;
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
@@ -631,7 +630,7 @@
int channel_num2 = voe_.GetLastChannel();
webrtc::CodecInst gcodec;
- rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "ISAC");
+ rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "ISAC");
gcodec.plfreq = 16000;
gcodec.channels = 1;
EXPECT_EQ(0, voe_.GetRecPayloadType(channel_num2, gcodec));
@@ -1983,7 +1982,7 @@
int channel_num = voe_.GetChannelFromLocalSsrc(ssrc);
EXPECT_TRUE(voe_.GetSend(channel_num));
}
- EXPECT_EQ(ARRAY_SIZE(kSsrcs4), call_.GetAudioSendStreams().size());
+ EXPECT_EQ(arraysize(kSsrcs4), call_.GetAudioSendStreams().size());
// Delete the send streams.
for (uint32_t ssrc : kSsrcs4) {
@@ -2088,7 +2087,7 @@
EXPECT_EQ(true, channel_->GetStats(&info));
// We have added 4 send streams. We should see empty stats for all.
- EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size());
+ EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
for (const auto& sender : info.senders) {
VerifyVoiceSenderInfo(sender, false);
}
@@ -2103,7 +2102,7 @@
cricket::VoiceMediaInfo info;
EXPECT_TRUE(channel_->RemoveRecvStream(kSsrc2));
EXPECT_EQ(true, channel_->GetStats(&info));
- EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size());
+ EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
EXPECT_EQ(0u, info.receivers.size());
}
@@ -2114,7 +2113,7 @@
DeliverPacket(kPcmuFrame, sizeof(kPcmuFrame));
SetAudioReceiveStreamStats();
EXPECT_EQ(true, channel_->GetStats(&info));
- EXPECT_EQ(static_cast<size_t>(ARRAY_SIZE(kSsrcs4)), info.senders.size());
+ EXPECT_EQ(static_cast<size_t>(arraysize(kSsrcs4)), info.senders.size());
EXPECT_EQ(1u, info.receivers.size());
VerifyVoiceReceiverInfo(info.receivers[0]);
}
@@ -2442,7 +2441,7 @@
int channel_num3 = voe_.GetLastChannel();
// Create packets with the right SSRCs.
char packets[4][sizeof(kPcmuFrame)];
- for (size_t i = 0; i < ARRAY_SIZE(packets); ++i) {
+ for (size_t i = 0; i < arraysize(packets); ++i) {
memcpy(packets[i], kPcmuFrame, sizeof(kPcmuFrame));
rtc::SetBE32(packets[i] + 8, static_cast<uint32_t>(i));
}
@@ -2507,7 +2506,7 @@
cricket::StreamParams::CreateLegacy(kSsrc1)));
int channel_num2 = voe_.GetLastChannel();
webrtc::CodecInst gcodec;
- rtc::strcpyn(gcodec.plname, ARRAY_SIZE(gcodec.plname), "opus");
+ rtc::strcpyn(gcodec.plname, arraysize(gcodec.plname), "opus");
gcodec.plfreq = 48000;
gcodec.channels = 2;
EXPECT_EQ(-1, voe_.GetRecPayloadType(channel_num2, gcodec));
@@ -3046,12 +3045,12 @@
EXPECT_TRUE(media_channel->SetSendParameters(send_parameters_));
static const uint32_t kSsrcs[] = {1, 2, 3, 4};
- for (unsigned int i = 0; i < ARRAY_SIZE(kSsrcs); ++i) {
+ for (unsigned int i = 0; i < arraysize(kSsrcs); ++i) {
EXPECT_TRUE(media_channel->AddRecvStream(
cricket::StreamParams::CreateLegacy(kSsrcs[i])));
EXPECT_NE(nullptr, call_.GetAudioReceiveStream(kSsrcs[i]));
}
- EXPECT_EQ(ARRAY_SIZE(kSsrcs), call_.GetAudioReceiveStreams().size());
+ EXPECT_EQ(arraysize(kSsrcs), call_.GetAudioReceiveStreams().size());
}
TEST_F(WebRtcVoiceEngineTestFake, ConfiguresAudioReceiveStreamRtpExtensions) {
@@ -3296,7 +3295,7 @@
cricket::VoiceMediaChannel* channels[32];
int num_channels = 0;
- while (num_channels < ARRAY_SIZE(channels)) {
+ while (num_channels < arraysize(channels)) {
cricket::VoiceMediaChannel* channel =
engine.CreateChannel(call.get(), cricket::AudioOptions());
if (!channel)
@@ -3304,7 +3303,7 @@
channels[num_channels++] = channel;
}
- int expected = ARRAY_SIZE(channels);
+ int expected = arraysize(channels);
EXPECT_EQ(expected, num_channels);
while (num_channels > 0) {
diff --git a/talk/session/media/channel_unittest.cc b/talk/session/media/channel_unittest.cc
index 1823320..28ab3d2 100644
--- a/talk/session/media/channel_unittest.cc
+++ b/talk/session/media/channel_unittest.cc
@@ -33,8 +33,9 @@
#include "talk/media/base/rtpdump.h"
#include "talk/media/base/screencastid.h"
#include "talk/media/base/testutils.h"
-#include "webrtc/p2p/base/faketransportcontroller.h"
#include "talk/session/media/channel.h"
+#include "webrtc/p2p/base/faketransportcontroller.h"
+#include "webrtc/base/arraysize.h"
#include "webrtc/base/fileutils.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/helpers.h"
@@ -2253,21 +2254,19 @@
}
TEST_F(VoiceChannelTest, SendBundleToBundle) {
- Base::SendBundleToBundle(kAudioPts, ARRAY_SIZE(kAudioPts), false, false);
+ Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, false);
}
TEST_F(VoiceChannelTest, SendBundleToBundleSecure) {
- Base::SendBundleToBundle(kAudioPts, ARRAY_SIZE(kAudioPts), false, true);
+ Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), false, true);
}
TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMux) {
- Base::SendBundleToBundle(
- kAudioPts, ARRAY_SIZE(kAudioPts), true, false);
+ Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, false);
}
TEST_F(VoiceChannelTest, SendBundleToBundleWithRtcpMuxSecure) {
- Base::SendBundleToBundle(
- kAudioPts, ARRAY_SIZE(kAudioPts), true, true);
+ Base::SendBundleToBundle(kAudioPts, arraysize(kAudioPts), true, true);
}
// VideoChannelTest
@@ -2501,21 +2500,19 @@
}
TEST_F(VideoChannelTest, SendBundleToBundle) {
- Base::SendBundleToBundle(kVideoPts, ARRAY_SIZE(kVideoPts), false, false);
+ Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, false);
}
TEST_F(VideoChannelTest, SendBundleToBundleSecure) {
- Base::SendBundleToBundle(kVideoPts, ARRAY_SIZE(kVideoPts), false, true);
+ Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), false, true);
}
TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMux) {
- Base::SendBundleToBundle(
- kVideoPts, ARRAY_SIZE(kVideoPts), true, false);
+ Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, false);
}
TEST_F(VideoChannelTest, SendBundleToBundleWithRtcpMuxSecure) {
- Base::SendBundleToBundle(
- kVideoPts, ARRAY_SIZE(kVideoPts), true, true);
+ Base::SendBundleToBundle(kVideoPts, arraysize(kVideoPts), true, true);
}
TEST_F(VideoChannelTest, TestSrtpError) {
diff --git a/webrtc/base/bitbuffer_unittest.cc b/webrtc/base/bitbuffer_unittest.cc
index 99701f7..ce42257 100644
--- a/webrtc/base/bitbuffer_unittest.cc
+++ b/webrtc/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/webrtc/base/bytebuffer_unittest.cc b/webrtc/base/bytebuffer_unittest.cc
index 56b0e05..0287d85 100644
--- a/webrtc/base/bytebuffer_unittest.cc
+++ b/webrtc/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/webrtc/base/common.h b/webrtc/base/common.h
index 67665f2..2086754 100644
--- a/webrtc/base/common.h
+++ b/webrtc/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/webrtc/base/crc32.cc b/webrtc/base/crc32.cc
index eae338a..f9e4c37 100644
--- a/webrtc/base/crc32.cc
+++ b/webrtc/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/webrtc/base/diskcache.cc b/webrtc/base/diskcache.cc
index 7bf1ba2..a1fba6a 100644
--- a/webrtc/base/diskcache.cc
+++ b/webrtc/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/webrtc/base/fileutils.cc b/webrtc/base/fileutils.cc
index 6f385d7..cb23153 100644
--- a/webrtc/base/fileutils.cc
+++ b/webrtc/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/webrtc/base/httpcommon-inl.h b/webrtc/base/httpcommon-inl.h
index d1c0bf0..188d9e6 100644
--- a/webrtc/base/httpcommon-inl.h
+++ b/webrtc/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/webrtc/base/httpcommon.cc b/webrtc/base/httpcommon.cc
index 0c3547e..c90bea5 100644
--- a/webrtc/base/httpcommon.cc
+++ b/webrtc/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/webrtc/base/natsocketfactory.cc b/webrtc/base/natsocketfactory.cc
index 548a80c..0abd2a1 100644
--- a/webrtc/base/natsocketfactory.cc
+++ b/webrtc/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/webrtc/base/openssladapter.cc b/webrtc/base/openssladapter.cc
index 892b5cc..1f5fbbc 100644
--- a/webrtc/base/openssladapter.cc
+++ b/webrtc/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/webrtc/base/physicalsocketserver.cc b/webrtc/base/physicalsocketserver.cc
index e0fe8a0..4a4c0a3 100644
--- a/webrtc/base/physicalsocketserver.cc
+++ b/webrtc/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/webrtc/base/proxydetect.cc b/webrtc/base/proxydetect.cc
index c0cfab9..30959ca 100644
--- a/webrtc/base/proxydetect.cc
+++ b/webrtc/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/webrtc/base/socket_unittest.cc b/webrtc/base/socket_unittest.cc
index d078d7c..8143823 100644
--- a/webrtc/base/socket_unittest.cc
+++ b/webrtc/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/webrtc/base/stringencode_unittest.cc b/webrtc/base/stringencode_unittest.cc
index 406d9c7..588e9d8 100644
--- a/webrtc/base/stringencode_unittest.cc
+++ b/webrtc/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/webrtc/base/task_unittest.cc b/webrtc/base/task_unittest.cc
index 7f67841..3508219 100644
--- a/webrtc/base/task_unittest.cc
+++ b/webrtc/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/webrtc/base/testutils.h b/webrtc/base/testutils.h
index e56895d..6e7e22a 100644
--- a/webrtc/base/testutils.h
+++ b/webrtc/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/webrtc/base/unixfilesystem.cc b/webrtc/base/unixfilesystem.cc
index 30d6e78..734e880 100644
--- a/webrtc/base/unixfilesystem.cc
+++ b/webrtc/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/webrtc/base/urlencode_unittest.cc b/webrtc/base/urlencode_unittest.cc
index 5216913..6a61db3 100644
--- a/webrtc/base/urlencode_unittest.cc
+++ b/webrtc/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/webrtc/base/virtualsocket_unittest.cc b/webrtc/base/virtualsocket_unittest.cc
index 694b154..68ad23b 100644
--- a/webrtc/base/virtualsocket_unittest.cc
+++ b/webrtc/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/webrtc/base/win32.cc b/webrtc/base/win32.cc
index 6e09829..182b84f 100644
--- a/webrtc/base/win32.cc
+++ b/webrtc/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/webrtc/base/win32filesystem.cc b/webrtc/base/win32filesystem.cc
index 8ac918f..b731974 100644
--- a/webrtc/base/win32filesystem.cc
+++ b/webrtc/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/webrtc/base/win32regkey_unittest.cc b/webrtc/base/win32regkey_unittest.cc
index 389c3a2..1702ef7 100644
--- a/webrtc/base/win32regkey_unittest.cc
+++ b/webrtc/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/webrtc/base/win32windowpicker.cc b/webrtc/base/win32windowpicker.cc
index b4550ae..da05a5c 100644
--- a/webrtc/base/win32windowpicker.cc
+++ b/webrtc/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/webrtc/base/win32windowpicker_unittest.cc b/webrtc/base/win32windowpicker_unittest.cc
index 71e8af6..701bb27 100644
--- a/webrtc/base/win32windowpicker_unittest.cc
+++ b/webrtc/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/webrtc/examples/peerconnection/client/defaults.cc b/webrtc/examples/peerconnection/client/defaults.cc
index 3090c15..f70aa72 100644
--- a/webrtc/examples/peerconnection/client/defaults.cc
+++ b/webrtc/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/webrtc/examples/peerconnection/client/main_wnd.cc b/webrtc/examples/peerconnection/client/main_wnd.cc
index 30b12a8..72f85b9 100644
--- a/webrtc/examples/peerconnection/client/main_wnd.cc
+++ b/webrtc/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/webrtc/libjingle/xmpp/chatroommoduleimpl.cc b/webrtc/libjingle/xmpp/chatroommoduleimpl.cc
index 546aa75..52fba4c 100644
--- a/webrtc/libjingle/xmpp/chatroommoduleimpl.cc
+++ b/webrtc/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/webrtc/libjingle/xmpp/presenceouttask.cc b/webrtc/libjingle/xmpp/presenceouttask.cc
index aa19c9d..5519a4f 100644
--- a/webrtc/libjingle/xmpp/presenceouttask.cc
+++ b/webrtc/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/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc
index f2ff768..2f54cb5 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test.cc
+++ b/webrtc/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/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc
index 6b3ce48..6245ccd 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/bwe_unittest.cc
+++ b/webrtc/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/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc
index 171d196..6166ff8 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/estimators/nada.cc
+++ b/webrtc/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/webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc
index a0f56b7..51afae1 100644
--- a/webrtc/modules/remote_bitrate_estimator/test/estimators/nada_unittest.cc
+++ b/webrtc/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/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc b/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc
index ceadf4c..7a7e3ed 100644
--- a/webrtc/modules/rtp_rtcp/source/h264_sps_parser_unittest.cc
+++ b/webrtc/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/webrtc/p2p/base/port_unittest.cc b/webrtc/p2p/base/port_unittest.cc
index c3e5df6..62ba572 100644
--- a/webrtc/p2p/base/port_unittest.cc
+++ b/webrtc/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/webrtc/p2p/base/pseudotcp.cc b/webrtc/p2p/base/pseudotcp.cc
index 5f035ca..6281315 100644
--- a/webrtc/p2p/base/pseudotcp.cc
+++ b/webrtc/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/webrtc/p2p/base/stun_unittest.cc b/webrtc/p2p/base/stun_unittest.cc
index cd4f7e1..1249257 100644
--- a/webrtc/p2p/base/stun_unittest.cc
+++ b/webrtc/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/webrtc/p2p/base/transportdescription.cc b/webrtc/p2p/base/transportdescription.cc
index 52033ec..0dcbac6 100644
--- a/webrtc/p2p/base/transportdescription.cc
+++ b/webrtc/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/webrtc/sound/alsasoundsystem.cc b/webrtc/sound/alsasoundsystem.cc
index 3cc77a9..3f97446 100644
--- a/webrtc/sound/alsasoundsystem.cc
+++ b/webrtc/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/webrtc/sound/automaticallychosensoundsystem_unittest.cc b/webrtc/sound/automaticallychosensoundsystem_unittest.cc
index 5cfd7c6..318385c 100644
--- a/webrtc/sound/automaticallychosensoundsystem_unittest.cc
+++ b/webrtc/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/webrtc/sound/linuxsoundsystem.h b/webrtc/sound/linuxsoundsystem.h
index 0016f8a..56721a1 100644
--- a/webrtc/sound/linuxsoundsystem.h
+++ b/webrtc/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/webrtc/sound/pulseaudiosoundsystem.cc b/webrtc/sound/pulseaudiosoundsystem.cc
index b44a1df..b1845f5 100644
--- a/webrtc/sound/pulseaudiosoundsystem.cc
+++ b/webrtc/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];