DespotifyUtils: use ARRAY_SIZE()

This commit is contained in:
Max Kellermann 2014-12-09 22:06:22 +01:00
parent 5f4252bcd2
commit fc0b6d143a

View File

@ -23,6 +23,7 @@
#include "config/ConfigGlobal.hxx" #include "config/ConfigGlobal.hxx"
#include "config/ConfigOption.hxx" #include "config/ConfigOption.hxx"
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "util/Macros.hxx"
#include "Log.hxx" #include "Log.hxx"
extern "C" { extern "C" {
@ -42,9 +43,7 @@ static void
callback(struct despotify_session* ds, int sig, callback(struct despotify_session* ds, int sig,
void *data, gcc_unused void *callback_data) void *data, gcc_unused void *callback_data)
{ {
size_t i; for (size_t i = 0; i < ARRAY_SIZE(registered_callbacks); ++i) {
for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
void (*cb)(struct despotify_session *, int, void *, void *) = registered_callbacks[i]; void (*cb)(struct despotify_session *, int, void *, void *) = registered_callbacks[i];
void *cb_data = registered_callback_data[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 *), bool mpd_despotify_register_callback(void (*cb)(struct despotify_session *, int, void *, void *),
void *cb_data) void *cb_data)
{ {
size_t i; for (size_t i = 0; i < ARRAY_SIZE(registered_callbacks); ++i) {
for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
if (!registered_callbacks[i]) { if (!registered_callbacks[i]) {
registered_callbacks[i] = cb; registered_callbacks[i] = cb;
registered_callback_data[i] = cb_data; 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 *)) void mpd_despotify_unregister_callback(void (*cb)(struct despotify_session *, int, void *, void *))
{ {
size_t i; for (size_t i = 0; i < ARRAY_SIZE(registered_callbacks); ++i) {
for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
if (registered_callbacks[i] == cb) { if (registered_callbacks[i] == cb) {
registered_callbacks[i] = nullptr; registered_callbacks[i] = nullptr;
} }