[PATCH 16/54] miinitext: Use ARRAY_SIZE rather than sentinel
Stéphane Marchesin
stephane.marchesin at gmail.com
Mon Jul 9 19:19:42 PDT 2012
On Mon, Jul 9, 2012 at 6:03 PM, Daniel Stone <daniel at fooishbar.org> wrote:
> NULL sentinels are totally lame.
>
> Signed-off-by: Daniel Stone <daniel at fooishbar.org>
Reviewed-by: Stéphane Marchesin <stephane.marchesin at gmail.com>
> ---
> 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
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
More information about the xorg-devel
mailing list