1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-19 12:28:22 +01:00

Changed formula for getting the number of elements in a static array

When using the formula [sizeof(array) / sizeof( x )] to get the number
of element in a static array, it is better to use array[0] for 'x'
instead of the base type of array:
 - in case the base type would change someday;
 - if the compiler were deciding to insert padding somewhere
This commit is contained in:
Christophe CURIS
2013-05-11 00:07:12 +02:00
committed by Carlos R. Mafra
parent e17a197bc4
commit 7f6699ffca
10 changed files with 18 additions and 18 deletions

View File

@@ -760,7 +760,7 @@ static void initDefaults()
WMPLSetCaseSensitive(False);
for (i = 0; i < sizeof(optionList) / sizeof(WDefaultEntry); i++) {
for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
entry = &optionList[i];
entry->plkey = WMCreatePLString(entry->key);
@@ -770,7 +770,7 @@ static void initDefaults()
entry->plvalue = NULL;
}
for (i = 0; i < sizeof(staticOptionList) / sizeof(WDefaultEntry); i++) {
for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
entry = &staticOptionList[i];
entry->plkey = WMCreatePLString(entry->key);
@@ -925,7 +925,7 @@ void wReadStaticDefaults(WMPropList * dict)
unsigned int i;
void *tdata;
for (i = 0; i < sizeof(staticOptionList) / sizeof(WDefaultEntry); i++) {
for (i = 0; i < sizeof(staticOptionList) / sizeof(staticOptionList[0]); i++) {
entry = &staticOptionList[i];
if (dict)
@@ -1079,7 +1079,7 @@ void wReadDefaults(WScreen * scr, WMPropList * new_dict)
needs_refresh = 0;
for (i = 0; i < sizeof(optionList) / sizeof(WDefaultEntry); i++) {
for (i = 0; i < sizeof(optionList) / sizeof(optionList[0]); i++) {
entry = &optionList[i];
if (new_dict)