diff options
author | Simon Howard | 2007-06-21 11:33:46 +0000 |
---|---|---|
committer | Simon Howard | 2007-06-21 11:33:46 +0000 |
commit | ed6191430b27a5447ef2675f2cfe19d8f0b88333 (patch) | |
tree | e7cd1d4d3d54a76717c6bc7f27050d865b4973bf /setup | |
parent | ee2a6fda9fd817c191d74d0f1a00a4c05b4ed433 (diff) | |
download | chocolate-doom-ed6191430b27a5447ef2675f2cfe19d8f0b88333.tar.gz chocolate-doom-ed6191430b27a5447ef2675f2cfe19d8f0b88333.tar.bz2 chocolate-doom-ed6191430b27a5447ef2675f2cfe19d8f0b88333.zip |
Add arrlen() macro as a clearer way of doing sizeof(array) /
sizeof(*array)
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 922
Diffstat (limited to 'setup')
-rw-r--r-- | setup/configfile.c | 5 | ||||
-rw-r--r-- | setup/keyboard.c | 3 | ||||
-rw-r--r-- | setup/mouse.c | 3 | ||||
-rw-r--r-- | setup/multiplayer.c | 5 |
4 files changed, 10 insertions, 6 deletions
diff --git a/setup/configfile.c b/setup/configfile.c index d9b17af2..984df6b2 100644 --- a/setup/configfile.c +++ b/setup/configfile.c @@ -44,6 +44,7 @@ #include "doomfeatures.h" #include "doomkeys.h" +#include "doomtype.h" #include "d_englsh.h" #include "m_argv.h" @@ -243,7 +244,7 @@ static default_t doom_defaults_list[] = static default_collection_t doom_defaults = { doom_defaults_list, - sizeof(doom_defaults_list) / sizeof(*doom_defaults_list), + arrlen(doom_defaults_list), NULL, }; @@ -282,7 +283,7 @@ static default_t extra_defaults_list[] = static default_collection_t extra_defaults = { extra_defaults_list, - sizeof(extra_defaults_list) / sizeof(*extra_defaults_list), + arrlen(extra_defaults_list), NULL, }; diff --git a/setup/keyboard.c b/setup/keyboard.c index e558840a..3a7ccb8f 100644 --- a/setup/keyboard.c +++ b/setup/keyboard.c @@ -19,6 +19,7 @@ // 02111-1307, USA. // #include "textscreen.h" +#include "doomtype.h" #include "execute.h" #include "txt_keyinput.h" @@ -72,7 +73,7 @@ static void KeySetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) TXT_CAST_ARG(int, variable); unsigned int i; - for (i=0; i<sizeof(allkeys) / sizeof(*allkeys); ++i) + for (i=0; i<arrlen(allkeys); ++i) { if (*variable == *allkeys[i] && allkeys[i] != variable) { diff --git a/setup/mouse.c b/setup/mouse.c index bafccc87..147c6938 100644 --- a/setup/mouse.c +++ b/setup/mouse.c @@ -22,6 +22,7 @@ #include <stdlib.h> #include "textscreen.h" +#include "doomtype.h" #include "execute.h" #include "txt_mouseinput.h" @@ -64,7 +65,7 @@ static void MouseSetCallback(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(variable)) // Check if the same mouse button is used for a different action // If so, set the other action(s) to -1 (unset) - for (i=0; i<sizeof(all_mouse_buttons) / sizeof(*all_mouse_buttons); ++i) + for (i=0; i<arrlen(all_mouse_buttons); ++i) { if (*all_mouse_buttons[i] == *variable && all_mouse_buttons[i] != variable) diff --git a/setup/multiplayer.c b/setup/multiplayer.c index e06fa6ab..5e35dbbc 100644 --- a/setup/multiplayer.c +++ b/setup/multiplayer.c @@ -24,6 +24,7 @@ #include "d_englsh.h" #include "textscreen.h" +#include "doomtype.h" #include "configfile.h" @@ -112,7 +113,7 @@ static iwad_t *GetIWADForDescription(char *description) { int i; - for (i=0; i<sizeof(iwads) / sizeof(*iwads); ++i) + for (i=0; i<arrlen(iwads); ++i) { if (!strcmp(iwads[i].description, description)) { @@ -405,7 +406,7 @@ static txt_widget_t *IWADSelector(void) num_iwads = 0; - for (i=0; i<sizeof(iwads) / sizeof(*iwads); ++i) + for (i=0; i<arrlen(iwads); ++i) { if (installed_iwads & iwads[i].mask) { |