Commit 76d8882f authored by Philippe Groarke's avatar Philippe Groarke Committed by Tristan Matthews

daemon: Change ARRAYSIZE to SFL_ARRAYSIZE

Avoids conflicts with third-party macros

Refs #58018

Change-Id: I4c3e8904656ccb1f5b44f1a06dc61c8f984ae612
parent e87e7462
......@@ -32,12 +32,12 @@
#define ARRAY_SIZE_H_
// Returns the number of elements in a, calculated at compile-time
#define ARRAYSIZE(a) \
#define SFL_ARRAYSIZE(a) \
((sizeof(a) / sizeof(*(a))) / \
static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
/* Only use this macro with string literals or character arrays, will not work
* as expected with char pointers */
#define CONST_PJ_STR(X) {(char *) (X), ARRAYSIZE(X) - 1}
#define CONST_PJ_STR(X) {(char *) (X), SFL_ARRAYSIZE(X) - 1}
#endif // ARRAY_SIZE_H_
......@@ -345,7 +345,7 @@ AudioCodecFactory::seemsValid(const std::string &lib)
};
const std::string name(lib.substr(prefix.length(), len));
const std::string *end = validCodecs + ARRAYSIZE(validCodecs);
const std::string *end = validCodecs + SFL_ARRAYSIZE(validCodecs);
return find(validCodecs, end, name) != end;
}
......
......@@ -265,7 +265,7 @@ OpenSLLayer::initAudioPlayback() const
SL_IID_PLAY};
const SLboolean req[] = {SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE};
const unsigned nbInterface = ARRAYSIZE(ids);
const unsigned nbInterface = SFL_ARRAYSIZE(ids);
// create audio player
DEBUG("Create audio player\n");
......
......@@ -121,7 +121,7 @@ Call::setState(CallState state)
std::lock_guard<std::mutex> lock(callMutex_);
if (not validTransition(state)) {
static const char *states[] = {"INACTIVE", "ACTIVE", "HOLD", "BUSY", "ERROR"};
assert(callState_ < ARRAYSIZE(states) and state < ARRAYSIZE(states));
assert(callState_ < SFL_ARRAYSIZE(states) and state < SFL_ARRAYSIZE(states));
ERROR("Invalid call state transition from %s to %s",
states[callState_], states[state]);
......
......@@ -61,7 +61,7 @@ static SipTransportBroker* instance = nullptr;
constexpr const char* TRANSPORT_STATE_STR[] = {
"CONNECTED", "DISCONNECTED", "SHUTDOWN", "DESTROY", "UNKNOWN STATE"
};
constexpr const size_t TRANSPORT_STATE_SZ = ARRAYSIZE(TRANSPORT_STATE_STR);
constexpr const size_t TRANSPORT_STATE_SZ = SFL_ARRAYSIZE(TRANSPORT_STATE_STR);
std::string
SipTransportDescr::toString() const
......
......@@ -351,7 +351,7 @@ transaction_request_cb(pjsip_rx_data *rdata)
CryptoOffer crypto_offer;
crypto_offer.push_back(std::string(sdpOffer.substr(start, (sdpOffer.size() - start) - 1)));
const size_t size = ARRAYSIZE(sfl::CryptoSuites);
const size_t size = SFL_ARRAYSIZE(sfl::CryptoSuites);
std::vector<sfl::CryptoSuiteDefinition> localCapabilities(size);
std::copy(sfl::CryptoSuites, sfl::CryptoSuites + size,
......@@ -1025,7 +1025,7 @@ sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status)
if (!crypto_offer.empty()) {
std::vector<sfl::CryptoSuiteDefinition> localCapabilities;
for (size_t i = 0; i < ARRAYSIZE(sfl::CryptoSuites); ++i)
for (size_t i = 0; i < SFL_ARRAYSIZE(sfl::CryptoSuites); ++i)
localCapabilities.push_back(sfl::CryptoSuites[i]);
sfl::SdesNegotiator sdesnego(localCapabilities, crypto_offer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment