aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/despotify
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-12-09 22:06:22 +0100
committerMax Kellermann <max@duempel.org>2014-12-09 22:06:22 +0100
commitfc0b6d143aadacc28c0039eaf21cb24826151974 (patch)
tree631e8f32285810b0606b27e7dfe21bb51af0c037 /src/lib/despotify
parent5f4252bcd2293597c331d24b6f13bd59b6afb145 (diff)
downloadmpd-fc0b6d143aadacc28c0039eaf21cb24826151974.tar.gz
mpd-fc0b6d143aadacc28c0039eaf21cb24826151974.tar.xz
mpd-fc0b6d143aadacc28c0039eaf21cb24826151974.zip
DespotifyUtils: use ARRAY_SIZE()
Diffstat (limited to 'src/lib/despotify')
-rw-r--r--src/lib/despotify/DespotifyUtils.cxx15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/lib/despotify/DespotifyUtils.cxx b/src/lib/despotify/DespotifyUtils.cxx
index f67679c50..c765c5336 100644
--- a/src/lib/despotify/DespotifyUtils.cxx
+++ b/src/lib/despotify/DespotifyUtils.cxx
@@ -23,6 +23,7 @@
#include "config/ConfigGlobal.hxx"
#include "config/ConfigOption.hxx"
#include "util/Domain.hxx"
+#include "util/Macros.hxx"
#include "Log.hxx"
extern "C" {
@@ -42,9 +43,7 @@ static void
callback(struct despotify_session* ds, int sig,
void *data, gcc_unused void *callback_data)
{
- size_t i;
-
- for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
+ for (size_t i = 0; i < ARRAY_SIZE(registered_callbacks); ++i) {
void (*cb)(struct despotify_session *, int, void *, void *) = registered_callbacks[i];
void *cb_data = registered_callback_data[i];
@@ -56,10 +55,7 @@ callback(struct despotify_session* ds, int sig,
bool mpd_despotify_register_callback(void (*cb)(struct despotify_session *, int, void *, void *),
void *cb_data)
{
- size_t i;
-
- for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
-
+ for (size_t i = 0; i < ARRAY_SIZE(registered_callbacks); ++i) {
if (!registered_callbacks[i]) {
registered_callbacks[i] = cb;
registered_callback_data[i] = cb_data;
@@ -73,10 +69,7 @@ bool mpd_despotify_register_callback(void (*cb)(struct despotify_session *, int,
void mpd_despotify_unregister_callback(void (*cb)(struct despotify_session *, int, void *, void *))
{
- size_t i;
-
- for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
-
+ for (size_t i = 0; i < ARRAY_SIZE(registered_callbacks); ++i) {
if (registered_callbacks[i] == cb) {
registered_callbacks[i] = nullptr;
}