Use G_N_ELEMENTS macro to calculate of array size.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2013-04-12 14:36:56 +04:00 committed by Slava Zanko
parent 9f80eda26e
commit 31bacf56c9
6 changed files with 7 additions and 10 deletions

View File

@ -306,7 +306,7 @@ mc_search_types_list_get (size_t * num)
{
/* don't count last NULL item */
if (num != NULL)
*num = sizeof (mc_search__list_types) / sizeof (mc_search__list_types[0]) - 1;
*num = G_N_ELEMENTS (mc_search__list_types) - 1;
return mc_search__list_types;
}

View File

@ -271,7 +271,7 @@ edit_find_filter (const vfs_path_t * filename_vpath)
filename = vfs_path_to_str (filename_vpath);
l = strlen (filename);
for (i = 0; i < sizeof (all_filters) / sizeof (all_filters[0]); i++)
for (i = 0; i < G_N_ELEMENTS (all_filters); i++)
{
e = strlen (all_filters[i].extension);
if (l > e)

View File

@ -1379,11 +1379,11 @@ panel_operate_generate_prompt (const WPanel * panel, FileOperation operation,
{
size_t i;
for (i = sizeof (op_names1) / sizeof (op_names1[0]); i--;)
for (i = G_N_ELEMENTS (op_names1); i-- != 0;)
op_names1[i] = Q_ (op_names1[i]);
#ifdef ENABLE_NLS
for (i = sizeof (prompt_parts) / sizeof (prompt_parts[0]); i--;)
for (i = G_N_ELEMENTS (prompt_parts); i-- != 0;)
prompt_parts[i] = _(prompt_parts[i]);
one_format = _(one_format);
@ -2680,7 +2680,7 @@ panel_operate (void *source_panel, FileOperation operation, gboolean force_singl
static gboolean i18n_flag = FALSE;
if (!i18n_flag)
{
for (i = sizeof (op_names) / sizeof (op_names[0]); i--;)
for (i = G_N_ELEMENTS (op_names); i-- != 0;)
op_names[i] = Q_ (op_names[i]);
i18n_flag = TRUE;
}

View File

@ -313,8 +313,6 @@ extern int saving_setup;
/*** file scope macro definitions ****************************************************************/
#define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
#define NORMAL 0
#define SELECTED 1
#define MARKED 2

View File

@ -230,7 +230,7 @@ mcview_init (mcview_t * view)
view->search_end = 0;
view->marker = 0;
for (i = 0; i < sizeof (view->marks) / sizeof (view->marks[0]); i++)
for (i = 0; i < G_N_ELEMENTS (view->marks); i++)
view->marks[i] = 0;
view->update_steps = 0;

View File

@ -9,8 +9,7 @@
/*** typedefs(not structures) and defined constants **********************************************/
#define mctest_add_parameterized_test(tc_core, test_func, test_data_source) {\
tcase_add_loop_test (tc_core, test_func, 0, \
sizeof (test_data_source) / sizeof (test_data_source[0])); \
tcase_add_loop_test (tc_core, test_func, 0, G_N_ELEMENTS (test_data_source)); \
}
#define mctest_assert_str_eq(actual_result, etalon_result) { \