From: Nanley Chery <nanley.g.ch...@intel.com> This variable existed to enable 0 as a valid error value for name_to_offset(). Since o(extension_sentinel) is also a valid error value, save space and replace this mysterious variable with a less mysterious one (extension_sentinel).
v2. Reword git comment and update function comment (Emil) Signed-off-by: Nanley Chery <nanley.g.ch...@intel.com> --- src/mesa/main/extensions.c | 11 ++++++----- src/mesa/main/mtypes.h | 3 +-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 3814633..b81bcc5 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -72,7 +72,7 @@ const struct mesa_extension _mesa_extension_table[] = { /** * Given an extension name, lookup up the corresponding member of struct * gl_extensions and return that member's offset (in bytes). If the name is - * not found in the \c _mesa_extension_table, return 0. + * not found in the \c _mesa_extension_table, return o(extension_sentinel). * * \param name Name of extension. * \return Offset of member in struct gl_extensions. @@ -81,16 +81,17 @@ static size_t name_to_offset(const char* name) { unsigned i; + const size_t error_value = o(extension_sentinel); if (name == 0) - return 0; + return error_value; for (i = 0; i < ARRAY_SIZE(_mesa_extension_table); ++i) { if (strcmp(name, _mesa_extension_table[i].name) == 0) return _mesa_extension_table[i].offset; } - return 0; + return error_value; } /** @@ -211,7 +212,7 @@ set_extension(struct gl_extensions *ext, const char *name, GLboolean state) size_t offset; offset = name_to_offset(name); - if (offset != 0 && (offset != o(dummy_true) || state != GL_FALSE)) { + if (offset != o(extension_sentinel) && (offset != o(dummy_true) || state != GL_FALSE)) { ((GLboolean *) ext)[offset] = state; } @@ -323,7 +324,7 @@ _mesa_one_time_init_extension_overrides(void) } offset = set_extension(&_mesa_extension_override_enables, ext, enable); - if (offset != 0 && (offset != o(dummy_true) || enable != GL_FALSE)) { + if (offset != o(extension_sentinel) && (offset != o(dummy_true) || enable != GL_FALSE)) { ((GLboolean *) &_mesa_extension_override_disables)[offset] = !enable; recognized = true; } else { diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 3a7759c..bfb85af 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3630,9 +3630,8 @@ struct gl_constants */ struct gl_extensions { - GLboolean dummy; /* don't remove this! */ GLboolean dummy_true; /* Set true by _mesa_init_extensions(). */ - GLboolean dummy_false; /* Set false by _mesa_init_extensions(). */ + GLboolean dummy_false; /* Set false by zeroed initialization. */ GLboolean ANGLE_texture_compression_dxt; GLboolean ARB_ES2_compatibility; GLboolean ARB_ES3_compatibility; -- 2.6.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev