Mesa (master): mesa: skip memmove in optimize_state_parameters if it's no-op
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jan 21 22:16:31 UTC 2021
Module: Mesa
Branch: master
Commit: 2a80595ba58c7d1a063973847dc5f2822dc3c406
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2a80595ba58c7d1a063973847dc5f2822dc3c406
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Dec 11 16:59:00 2020 -0500
mesa: skip memmove in optimize_state_parameters if it's no-op
This doesn't change the behavior. Check if there is at least 1 element
that follows removed parameters.
Reviewed-by: Eric Anholt <eric at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8183>
---
src/mesa/program/prog_statevars.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
index 81a821d9972..70c1aab3543 100644
--- a/src/mesa/program/prog_statevars.c
+++ b/src/mesa/program/prog_statevars.c
@@ -1349,10 +1349,12 @@ _mesa_optimize_state_parameters(struct gl_constants *consts,
free((char*)list->Parameters[i].Name);
/* Remove the merged state vars. */
- memmove(&list->Parameters[first_param + 1],
- &list->Parameters[last_param + 1],
- sizeof(list->Parameters[0]) *
- (list->NumParameters - last_param - 1));
+ if (last_param + 1 < list->NumParameters) {
+ memmove(&list->Parameters[first_param + 1],
+ &list->Parameters[last_param + 1],
+ sizeof(list->Parameters[0]) *
+ (list->NumParameters - last_param - 1));
+ }
list->NumParameters -= param_diff;
}
}
More information about the mesa-commit
mailing list