1
0
mirror of https://github.com/gryf/wmaker.git synced 2025-12-20 21:08:08 +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

@@ -482,7 +482,7 @@ void StartUp(Bool defaultScreenOnly)
#ifdef HAVE_XRANDR
int dummy;
#endif
Atom atom[sizeof(atomNames) / sizeof(char *)];
Atom atom[sizeof(atomNames) / sizeof(atomNames[0])];
/*
* Ignore CapsLock in modifiers
@@ -505,12 +505,12 @@ void StartUp(Bool defaultScreenOnly)
/* _XA_VERSION = XInternAtom(dpy, "VERSION", False); */
#ifdef HAVE_XINTERNATOMS
XInternAtoms(dpy, atomNames, sizeof(atomNames) / sizeof(char *), False, atom);
XInternAtoms(dpy, atomNames, sizeof(atomNames) / sizeof(atomNames[0]), False, atom);
#else
{
int i;
for (i = 0; i < sizeof(atomNames) / sizeof(char *); i++)
for (i = 0; i < sizeof(atomNames) / sizeof(atomNames[0]); i++)
atom[i] = XInternAtom(dpy, atomNames[i], False);
}
#endif