3 ms·
What is the best alternative when I want to allocate some reasonably sized array on the stack and don’t want to always reserve the worst case size? alloca?
by google234123 4y ago
What is the best alternative when I want to allocate some reasonably sized array on the stack and don’t want to always reserve the worst case size? alloca?
- tedunangst 4y agoReserve the maximum every time.
- cozzyd 4y agoThat has cache friendliness implications though, doesn't it? Seems better to just cap the size of the allocation and use a VLA.
- enriquto 4y agoYou don't need an alternative. VLAs are perfectly appropriate for that use case.