mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-22 14:08:06 +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:
committed by
Carlos R. Mafra
parent
e17a197bc4
commit
7f6699ffca
@@ -105,7 +105,7 @@ static char *mapWeightToName(str * weight)
|
||||
if (weight->len == 0)
|
||||
return "";
|
||||
|
||||
for (i = 0; i < sizeof(normalNames) / sizeof(char *); i++) {
|
||||
for (i = 0; i < sizeof(normalNames) / sizeof(normalNames[0]); i++) {
|
||||
if (strlen(normalNames[i]) == weight->len && strncmp(normalNames[i], weight->str, weight->len)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user