HackerTrans
TopNewTrendsCommentsPastAskShowJobs

Avoiding Malloc for Small Strings in C with Variable Length Arrays (VLAs)(medium.com)

2 points·by yairlenga·há 3 meses·1 comments
medium.com
Avoiding Malloc for Small Strings in C with Variable Length Arrays (VLAs)

https://medium.com/@yair.lenga/avoiding-malloc-for-small-strings-in-c-with-variable-length-arrays-vlas-7b1fbcae7193

1 comments

yairlenga·há 3 meses
This looks at replacing malloc/free for small temporary strings with VLAs, using a stack-first approach with heap fallback. Benchmarks were a bit surprising—allocator behavior (especially on musl) changes the trade-offs more than I expected. Interested in how others approach temporary allocation patterns.