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 codebase #628

charles-lunarg opened this issue Jul 29, 2021 · 0 comments

Remove alloca() from codebase #628

charles-lunarg opened this issue Jul 29, 2021 · 0 comments


Copy link

@charles-lunarg charles-lunarg commented Jul 29, 2021

alloca() is not considered good practice, since it has numerous issues:

  1. Non-standardized behavior across compilers
  2. Stack space is limited and all too easy to exhaust
  3. Scope is tied to stack, which limits useability

A better solution would be to create a stack allocator that can easily have memory gotten from it for scratch allocations. Such a solution would:

  • Let the program control the lifetime with explicit 'clear' calls
  • Not be restricted to the stack frame (but would require closer attention to when/where clear is called)

There was already a previous crash that occurred due to alloca being used in json parsing. A stack allocator could easily handle 'out of space' by allocating a new heap to use if need be.

@charles-lunarg charles-lunarg added this to the P3 milestone Jul 29, 2021
@charles-lunarg charles-lunarg self-assigned this Jul 29, 2021
@charles-lunarg charles-lunarg added the enhancement label Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant