Skip to content

Commit

Permalink
pull sizeof trickery out to ARRAY_LEN macro
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco149 committed May 15, 2018
1 parent 498dd75 commit 1ea295b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)
#define ARRAY_LEN(x) (sizeof(x) / sizeof((x)[0]))

#define OPPAI_VERSION_STRING \
STRINGIFY(OPPAI_VERSION_MAJOR) "." \
Expand Down Expand Up @@ -201,8 +202,7 @@ void asciiplt(float (* getvalue)(void* data, size_t i), size_t n,
#endif
};

static size_t const charsetsize =
sizeof(charset) / sizeof(charset[0]);
static size_t const charsetsize = ARRAY_LEN(charset);

float values[ASCIIPLT_W];
float minval = (float)get_inf();
Expand Down Expand Up @@ -926,7 +926,7 @@ output_by_name(char const* name)
{
int32_t i;

for (i = 0; i < sizeof(modules) / sizeof(modules[0]); ++i)
for (i = 0; i < ARRAY_LEN(modules); ++i)
{
if (!strcmp(modules[i].name, name)) {
return &modules[i];
Expand Down
2 changes: 1 addition & 1 deletion oppai.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

#define OPPAI_VERSION_MAJOR 1
#define OPPAI_VERSION_MINOR 1
#define OPPAI_VERSION_PATCH 51
#define OPPAI_VERSION_PATCH 52

/* if your compiler doesn't have stdint, define this */
#ifdef OPPAI_NOSTDINT
Expand Down

0 comments on commit 1ea295b

Please sign in to comment.