Not really a C++ dev, I like my C. I know the difference between a static and dynamic type lol, that wasn’t my question.
Also worth noting, I think there’s slightly more to it than your explanation, alloca let’s you create a dynamically sized buffer, but said buffer is not dynamically resizable (or freeable). Once created it’s on the stack until the end of the function call.
(So once created, alloca also has a fixed size, just like char[].)
You can free malloc calls and ‘resize’ them (which could simply extend or move when extending isn’t possible). alloca behaves similarly to char[] in that it can’t be freed (or resized).
View all comments
Show parent comment
2
u/vip17 Sep 10 '26
a
char[]has fixed size,allocaallows dynamic size. It's likestd::inplace_vectorin C++26 or boostsmall_vectorandstatic_vector