summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nasmlib.c2
-rw-r--r--nasmlib.h3
-rw-r--r--output/outform.c4
-rw-r--r--preproc.c6
4 files changed, 7 insertions, 8 deletions
diff --git a/nasmlib.c b/nasmlib.c
index 2ae8619..460186e 100644
--- a/nasmlib.c
+++ b/nasmlib.c
@@ -570,7 +570,7 @@ static const char *prefix_names[] = {
const char *prefix_name(int token)
{
unsigned int prefix = token-PREFIX_ENUM_START;
- if (prefix > elements(prefix_names))
+ if (prefix >= ARRAY_SIZE(prefix_names))
return NULL;
return prefix_names[prefix];
diff --git a/nasmlib.h b/nasmlib.h
index 02876c7..2c335e1 100644
--- a/nasmlib.h
+++ b/nasmlib.h
@@ -239,8 +239,7 @@ void standard_extension(char *inname, char *outname, char *extension);
* This is a useful #define which I keep meaning to use more often:
* the number of elements of a statically defined array.
*/
-
-#define elements(x) ( sizeof(x) / sizeof(*(x)) )
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
/*
* List handling
diff --git a/output/outform.c b/output/outform.c
index f5b6739..e386343 100644
--- a/output/outform.c
+++ b/output/outform.c
@@ -59,7 +59,7 @@ struct ofmt *ofmt_find(char *name)
}
/* lets walk thru aliases then */
- for (i = 0; i < elements(ofmt_aliases); i++) {
+ for (i = 0; i < ARRAY_SIZE(ofmt_aliases); i++) {
if (ofmt_aliases[i].shortname &&
!nasm_stricmp(name, ofmt_aliases[i].shortname))
return ofmt_aliases[i].ofmt;
@@ -92,7 +92,7 @@ void ofmt_list(struct ofmt *deffmt, FILE * fp)
}
/* lets walk through aliases then */
- for (i = 0; i < elements(ofmt_aliases); i++) {
+ for (i = 0; i < ARRAY_SIZE(ofmt_aliases); i++) {
if (!ofmt_aliases[i].shortname)
continue;
fprintf(fp, " %-10s%s\n",
diff --git a/preproc.c b/preproc.c
index 2e870e5..7bfe214 100644
--- a/preproc.c
+++ b/preproc.c
@@ -482,7 +482,7 @@ static char *check_tasm_directive(char *line)
/* Binary search for the directive name */
i = -1;
- j = elements(tasm_directives);
+ j = ARRAY_SIZE(tasm_directives);
q = nasm_skip_word(p);
len = q - p;
if (len) {
@@ -2005,7 +2005,7 @@ static int parse_size(const char *str) {
static const int sizes[] =
{ 0, 1, 4, 16, 8, 10, 2, 32 };
- return sizes[bsii(str, size_names, elements(size_names))+1];
+ return sizes[bsii(str, size_names, ARRAY_SIZE(size_names))+1];
}
/*
@@ -3469,7 +3469,7 @@ static int find_cc(Token * t)
return -1;
i = -1;
- j = elements(conditions);
+ j = ARRAY_SIZE(conditions);
while (j - i > 1) {
k = (j + i) / 2;
m = nasm_stricmp(t->text, conditions[k]);