alloca() is not considered good practice, since it has numerous issues:
Non-standardized behavior across compilers
Stack space is limited and all too easy to exhaust
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.
The text was updated successfully, but these errors were encountered:
alloca()
is not considered good practice, since it has numerous issues: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:
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.
The text was updated successfully, but these errors were encountered: