[PATCH 16/54] miinitext: Use ARRAY_SIZE rather than sentinel
Daniel Stone
daniel at fooishbar.org
Mon Jul 9 18:03:00 PDT 2012
NULL sentinels are totally lame.
Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
mi/miinitext.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/mi/miinitext.c b/mi/miinitext.c
index ef20a11..c4749f5 100644
--- a/mi/miinitext.c
+++ b/mi/miinitext.c
@@ -172,15 +172,16 @@ static ExtensionToggle ExtensionToggleList[] = {
#ifdef XV
{"XVideo", &noXvExtension},
#endif
- {NULL, NULL}
};
Bool
EnableDisableExtension(const char *name, Bool enable)
{
- ExtensionToggle *ext = &ExtensionToggleList[0];
+ ExtensionToggle *ext;
+ int i;
- for (ext = &ExtensionToggleList[0]; ext->name != NULL; ext++) {
+ for (i = 0; i < ARRAY_SIZE(ExtensionToggleList); i++) {
+ ext = &ExtensionToggleList[i];
if (strcmp(name, ext->name) == 0) {
if (ext->disablePtr != NULL) {
*ext->disablePtr = !enable;
@@ -396,7 +397,6 @@ static ExtensionModule staticExtensions[] = {
#ifdef DAMAGE
{DamageExtensionInit, "DAMAGE", &noDamageExtension, NULL},
#endif
- {NULL, NULL, NULL, NULL, NULL}
};
/*ARGSUSED*/ void
@@ -408,7 +408,7 @@ InitExtensions(int argc, char *argv[])
if (!listInitialised) {
/* Add built-in extensions to the list. */
- for (i = 0; staticExtensions[i].name; i++)
+ for (i = 0; i < ARRAY_SIZE(staticExtensions); i++)
LoadExtension(&staticExtensions[i], TRUE);
/* Sort the extensions according the init dependencies. */
@@ -416,7 +416,7 @@ InitExtensions(int argc, char *argv[])
listInitialised = TRUE;
}
- for (i = 0; ExtensionModuleList[i].name != NULL; i++) {
+ for (i = 0; i < numExtensionModules; i++) {
ext = &ExtensionModuleList[i];
if (ext->initFunc != NULL &&
(ext->disablePtr == NULL || !*ext->disablePtr)) {
--
1.7.10.4
More information about the xorg-devel
mailing list