mirror of
https://github.com/gryf/wmaker.git
synced 2026-01-23 23:55:45 +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
@@ -552,7 +552,7 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * c
|
||||
"_NET_WM_ICON_NAME",
|
||||
"_NET_WM_ICON",
|
||||
};
|
||||
Atom atoms[sizeof(atomNames) / sizeof(char *)];
|
||||
Atom atoms[sizeof(atomNames) / sizeof(atomNames[0])];
|
||||
int i;
|
||||
|
||||
if (!initialized) {
|
||||
@@ -803,9 +803,9 @@ WMScreen *WMCreateScreenWithRContext(Display * display, int screen, RContext * c
|
||||
}
|
||||
|
||||
#ifdef HAVE_XINTERNATOMS
|
||||
XInternAtoms(display, atomNames, sizeof(atomNames) / sizeof(char *), False, atoms);
|
||||
XInternAtoms(display, atomNames, sizeof(atomNames) / sizeof(atomNames[0]), False, atoms);
|
||||
#else
|
||||
for (i = 0; i < sizeof(atomNames) / sizeof(char *); i++) {
|
||||
for (i = 0; i < sizeof(atomNames) / sizeof(atomNames[0]); i++) {
|
||||
atoms[i] = XInternAtom(display, atomNames[i], False);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user