Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove alloca from loop and use a single fixed size array declaration #48926

Merged
merged 1 commit into from
May 21, 2021

Conversation

madmiraal
Copy link
Contributor

As identified by lgtm, #38645 introduced alloca in a loop. Unlike memory allocated to a variable, which is reused on every iteration, memory allocated by alloca is not freed until the calling function returns. Not only does this run the risk of causing a stack overflow, but it neither needs alloca nor be inside the loop. First, the memory can be allocated using a standard fixed size array, and second, the array can be reused.

This PR changes the declaration of argptrs to a fixed size array of const Variant pointers and moves the declaration outside the loop.

@madmiraal madmiraal added this to the 4.0 milestone May 21, 2021
@madmiraal madmiraal requested a review from a team as a code owner May 21, 2021 12:36
@akien-mga akien-mga merged commit 31bd2cc into godotengine:master May 21, 2021
@akien-mga
Copy link
Member

Thanks!

@madmiraal madmiraal deleted the fix-38645 branch May 21, 2021 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants