summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2017-10-25 11:33:09 +0100
committerEmil Velikov <[email protected]>2017-11-16 14:07:14 +0000
commit3d81e11b49366b5636b8524ba0f8c7076e3fdf34 (patch)
tree1369aac5e6e16582ded76a600fb344a970fd5e9e /src/mesa
parenta3f82876f4471b88158074766c6115e15642d734 (diff)
mesa: remove unnecessary 'sort by year' for the GL extensions
The sorting was originally added to work around broken games (comment says Quake3 demo) that were copying the extensions list into small buffer. Sorting does not solve the problem, since we'll still overflow and cause corruption/crash. Better workaround is to actually trim the string ... as done with a later commit which introduces the MESA_EXTENSION_MAX_YEAR env. variable. Side note: On my machine, the existing sorting makes no changes to the extensions string. Cc: Jose Fonseca <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/main/extensions.c53
1 files changed, 3 insertions, 50 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c
index 2468e19bf99..7483b8f2496 100644
--- a/src/mesa/main/extensions.c
+++ b/src/mesa/main/extensions.c
@@ -352,30 +352,6 @@ _mesa_extension_supported(const struct gl_context *ctx, extension_index i)
return (ctx->Version >= ext->version[ctx->API]) && base[ext->offset];
}
-/**
- * Compare two entries of the extensions table. Sorts first by year,
- * then by name.
- *
- * Arguments are indices into _mesa_extension_table.
- */
-static int
-extension_compare(const void *p1, const void *p2)
-{
- extension_index i1 = * (const extension_index *) p1;
- extension_index i2 = * (const extension_index *) p2;
- const struct mesa_extension *e1 = &_mesa_extension_table[i1];
- const struct mesa_extension *e2 = &_mesa_extension_table[i2];
- int res;
-
- res = (int)e1->year - (int)e2->year;
-
- if (res == 0) {
- res = strcmp(e1->name, e2->name);
- }
-
- return res;
-}
-
/**
* Construct the GL_EXTENSIONS string. Called the first time that
@@ -391,7 +367,7 @@ _mesa_make_extension_string(struct gl_context *ctx)
/* Number of extensions */
unsigned count;
/* Indices of the extensions sorted by year */
- extension_index *extension_indices;
+ extension_index extension_indices[MESA_EXTENSION_COUNT];
/* String of extra extensions. */
const char *extra_extensions = get_extension_override(ctx);
unsigned k;
@@ -415,8 +391,8 @@ _mesa_make_extension_string(struct gl_context *ctx)
if (i->year <= maxYear &&
_mesa_extension_supported(ctx, k)) {
- length += strlen(i->name) + 1; /* +1 for space */
- ++count;
+ length += strlen(i->name) + 1; /* +1 for space */
+ extension_indices[count++] = k;
}
}
if (extra_extensions != NULL)
@@ -427,28 +403,6 @@ _mesa_make_extension_string(struct gl_context *ctx)
return NULL;
}
- extension_indices = malloc(count * sizeof(extension_index));
- if (extension_indices == NULL) {
- free(exts);
- return NULL;
- }
-
- /* Sort extensions in chronological order because certain old applications
- * (e.g., Quake3 demo) store the extension list in a static size buffer so
- * chronologically order ensure that the extensions that such applications
- * expect will fit into that buffer.
- */
- j = 0;
- for (k = 0; k < MESA_EXTENSION_COUNT; ++k) {
- if (_mesa_extension_table[k].year <= maxYear &&
- _mesa_extension_supported(ctx, k)) {
- extension_indices[j++] = k;
- }
- }
- assert(j == count);
- qsort(extension_indices, count,
- sizeof *extension_indices, extension_compare);
-
/* Build the extension string.*/
for (j = 0; j < count; ++j) {
const struct mesa_extension *i = &_mesa_extension_table[extension_indices[j]];
@@ -456,7 +410,6 @@ _mesa_make_extension_string(struct gl_context *ctx)
strcat(exts, i->name);
strcat(exts, " ");
}
- free(extension_indices);
if (extra_extensions != 0) {
strcat(exts, extra_extensions);
}