diff options
author | Emil Velikov <[email protected]> | 2017-10-24 14:35:41 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-11-16 14:07:14 +0000 |
commit | 444d9e4b081ab18352fc30a3c90829536ddd49fb (patch) | |
tree | 74ffbcabd8119c52b17ce6e2b58d04486ebe61ae /src/mesa | |
parent | e4cdce50585edbbbe9b6fe0d3f7215a67b989309 (diff) |
mesa: drop unnecessary coping of extra_extensions
The function get_extension_override() returns a copy of a string,
only for it to be copied again ...
Drop the unneeded calloc/strdup/free dance.
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.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 87f60d58c67..351ed1c4dd4 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -198,18 +198,16 @@ set_extension(struct gl_extensions *ext, int i, GLboolean state) /** * The unrecognized extensions from \c MESA_EXTENSION_OVERRIDE. - * Must be freed, does not return \c NULL. + * Returns \c NULL if empty. */ -static char * +static const char * get_extension_override( struct gl_context *ctx ) { - if (extra_extensions == NULL) { - return calloc(1, sizeof(char)); - } else { + if (extra_extensions) _mesa_problem(ctx, "Trying to enable unknown extensions: %s", extra_extensions); - return strdup(extra_extensions); - } + + return extra_extensions; } @@ -396,7 +394,7 @@ _mesa_make_extension_string(struct gl_context *ctx) /* Indices of the extensions sorted by year */ extension_index *extension_indices; /* String of extra extensions. */ - char *extra_extensions = get_extension_override(ctx); + const char *extra_extensions = get_extension_override(ctx); unsigned k; unsigned j; unsigned maxYear = ~0; @@ -427,14 +425,12 @@ _mesa_make_extension_string(struct gl_context *ctx) exts = calloc(ALIGN(length + 1, 4), sizeof(char)); if (exts == NULL) { - free(extra_extensions); return NULL; } extension_indices = malloc(count * sizeof(extension_index)); if (extension_indices == NULL) { free(exts); - free(extra_extensions); return NULL; } @@ -464,7 +460,6 @@ _mesa_make_extension_string(struct gl_context *ctx) free(extension_indices); if (extra_extensions != 0) { strcat(exts, extra_extensions); - free(extra_extensions); } return (GLubyte *) exts; |