Skip to content

Commit

Permalink
Use the ARRLEN macro in more places and remove an unused macro. (#5260
Browse files Browse the repository at this point in the history
)
  • Loading branch information
red-001 authored and nerzhul committed Feb 18, 2017
1 parent 3d25914 commit d988f9b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/clientiface.h
Expand Up @@ -165,7 +165,6 @@ namespace con {
class Connection;
}

#define CI_ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0]))

// Also make sure to update the ClientInterface::statenames
// array when modifying these enums
Expand Down
8 changes: 4 additions & 4 deletions src/keycode.cpp
Expand Up @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "debug.h"
#include "util/hex.h"
#include "util/string.h"
#include "util/basic_macros.h"

class UnknownKeycode : public BaseException
{
Expand Down Expand Up @@ -242,11 +243,10 @@ static const struct table_key table[] = {

#undef N_

#define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0]))

struct table_key lookup_keyname(const char *name)
{
for (u16 i = 0; i < ARRAYSIZE(table); i++) {
for (u16 i = 0; i < ARRLEN(table); i++) {
if (strcmp(table[i].Name, name) == 0)
return table[i];
}
Expand All @@ -256,7 +256,7 @@ struct table_key lookup_keyname(const char *name)

struct table_key lookup_keykey(irr::EKEY_CODE key)
{
for (u16 i = 0; i < ARRAYSIZE(table); i++) {
for (u16 i = 0; i < ARRLEN(table); i++) {
if (table[i].Key == key)
return table[i];
}
Expand All @@ -268,7 +268,7 @@ struct table_key lookup_keykey(irr::EKEY_CODE key)

struct table_key lookup_keychar(wchar_t Char)
{
for (u16 i = 0; i < ARRAYSIZE(table); i++) {
for (u16 i = 0; i < ARRLEN(table); i++) {
if (table[i].Char == Char)
return table[i];
}
Expand Down

0 comments on commit d988f9b

Please sign in to comment.