From: Nanley Chery <nanley.g.ch...@intel.com>

Simplify future updates to the extension struct array by removing
the sentinel.

Signed-off-by: Nanley Chery <nanley.g.ch...@intel.com>
---
 src/mesa/main/extensions.c | 43 +++++++++++++++++++++++++------------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index b2c88c3..389bbb0 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -405,8 +405,6 @@ static const struct extension extension_table[] = {
    { "GL_SGIS_texture_edge_clamp",                 o(dummy_true),              
                GLL,            1997 },
    { "GL_SGIS_texture_lod",                        o(dummy_true),              
                GLL,            1997 },
    { "GL_SUN_multi_draw_arrays",                   o(dummy_true),              
                GLL,            1999 },
-
-   { 0, 0, 0, 0 },
 };
 
 
@@ -421,14 +419,14 @@ static const struct extension extension_table[] = {
 static size_t
 name_to_offset(const char* name)
 {
-   const struct extension *i;
+   unsigned i;
 
    if (name == 0)
       return 0;
 
-   for (i = extension_table; i->name != 0; ++i) {
-      if (strcmp(name, i->name) == 0)
-        return i->offset;
+   for (i = 0; i < ARRAY_SIZE(extension_table); ++i) {
+      if (strcmp(name, extension_table[i].name) == 0)
+        return extension_table[i].offset;
    }
 
    return 0;
@@ -441,15 +439,16 @@ name_to_offset(const char* name)
 static void
 override_extensions_in_context(struct gl_context *ctx)
 {
-   const struct extension *i;
+   unsigned i;
    const GLboolean *enables =
       (GLboolean*) &_mesa_extension_override_enables;
    const GLboolean *disables =
       (GLboolean*) &_mesa_extension_override_disables;
    GLboolean *ctx_ext = (GLboolean*)&ctx->Extensions;
 
-   for (i = extension_table; i->name != 0; ++i) {
-      size_t offset = i->offset;
+   for (i = 0; i < ARRAY_SIZE(extension_table); ++i) {
+      size_t offset = extension_table[i].offset;
+
       assert(!enables[offset] || !disables[offset]);
       if (enables[offset]) {
          ctx_ext[offset] = 1;
@@ -773,7 +772,7 @@ _mesa_make_extension_string(struct gl_context *ctx)
    /* String of extra extensions. */
    char *extra_extensions = get_extension_override(ctx);
    GLboolean *base = (GLboolean *) &ctx->Extensions;
-   const struct extension *i;
+   unsigned k;
    unsigned j;
    unsigned maxYear = ~0;
    unsigned api_set = (1 << ctx->API);
@@ -794,7 +793,9 @@ _mesa_make_extension_string(struct gl_context *ctx)
 
    /* Compute length of the extension string. */
    count = 0;
-   for (i = extension_table; i->name != 0; ++i) {
+   for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
+      const struct extension *i = extension_table + k;
+
       if (base[i->offset] &&
           i->year <= maxYear &&
           (i->api_set & api_set)) {
@@ -824,11 +825,13 @@ _mesa_make_extension_string(struct gl_context *ctx)
     * expect will fit into that buffer.
     */
    j = 0;
-   for (i = extension_table; i->name != 0; ++i) {
+   for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
+      const struct extension *i = extension_table + k;
+
       if (base[i->offset] &&
           i->year <= maxYear &&
           (i->api_set & api_set)) {
-         extension_indices[j++] = i - extension_table;
+         extension_indices[j++] = k;
       }
    }
    assert(j == count);
@@ -837,7 +840,7 @@ _mesa_make_extension_string(struct gl_context *ctx)
 
    /* Build the extension string.*/
    for (j = 0; j < count; ++j) {
-      i = &extension_table[extension_indices[j]];
+      const struct extension *i = &extension_table[extension_indices[j]];
       assert(base[i->offset] && (i->api_set & api_set));
       strcat(exts, i->name);
       strcat(exts, " ");
@@ -858,7 +861,7 @@ GLuint
 _mesa_get_extension_count(struct gl_context *ctx)
 {
    GLboolean *base;
-   const struct extension *i;
+   unsigned k;
    unsigned api_set = (1 << ctx->API);
    if (_mesa_is_gles3(ctx))
       api_set |= ES3;
@@ -870,7 +873,9 @@ _mesa_get_extension_count(struct gl_context *ctx)
       return ctx->Extensions.Count;
 
    base = (GLboolean *) &ctx->Extensions;
-   for (i = extension_table; i->name != 0; ++i) {
+   for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
+      const struct extension *i = extension_table + k;
+
       if (base[i->offset] && (i->api_set & api_set)) {
         ctx->Extensions.Count++;
       }
@@ -886,7 +891,7 @@ _mesa_get_enabled_extension(struct gl_context *ctx, GLuint 
index)
 {
    const GLboolean *base;
    size_t n;
-   const struct extension *i;
+   unsigned k;
    unsigned api_set = (1 << ctx->API);
    if (_mesa_is_gles3(ctx))
       api_set |= ES3;
@@ -895,7 +900,9 @@ _mesa_get_enabled_extension(struct gl_context *ctx, GLuint 
index)
 
    base = (GLboolean*) &ctx->Extensions;
    n = 0;
-   for (i = extension_table; i->name != 0; ++i) {
+   for (k = 0; k < ARRAY_SIZE(extension_table); ++k) {
+      const struct extension *i = extension_table + k;
+
       if (base[i->offset] && (i->api_set & api_set)) {
          if (n == index)
             return (const GLubyte*) i->name;
-- 
2.6.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to