Refactoring. Improve code reuse ratio.

Add ARRAY_SIZE() macro.

Use the new macro in all places where array size is calculated by
means of sizeof(array)/sizeof(array[0]).

Fix minor bugs and warnings in the affected code.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin
2018-08-14 16:41:52 +03:00
parent 232773d171
commit bb1a4cc805
6 changed files with 16 additions and 16 deletions

View File

@@ -38,6 +38,8 @@
#include <stdio.h>
#include <string.h>
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#ifndef TRUE
#define TRUE 1
#endif

View File

@@ -327,8 +327,7 @@ pef_b2s_generic_ER[] __attribute__((unused)) = {
&pef_b2s_gentype_11,
&pef_b2s_gentype_12,
};
#define PEF_B2S_GENERIC_ER_ENTRIES \
(sizeof(pef_b2s_generic_ER) / sizeof(pef_b2s_generic_ER[0]))
#define PEF_B2S_GENERIC_ER_ENTRIES ARRAY_SIZE(pef_b2s_generic_ER)
#ifdef HAVE_PRAGMA_PACK
#pragma pack(1)