I've read quite a few places that alloca
is obsolete and should not be used and Variable Length Arrays should be used instead.
My question is this: Is alloca
completely replaceable by variable length arrays?
In my particular instance I have something that looks like this:
typedef struct {
int *value;
size_t size;
} some_type;
void SomeExternalFunction(some_type);
...
void foo(){
//What I thought to do
some_type bar;
bar.value=alloca(sizeof(int)*10);
SomeExternalFunction(bar);
//what should be done without alloca
some_type fizz;
int tmp[10];
fizz.value=tmp;
SoemExternalFunction(fizz);
}
Am I missing something or is this an actual good use of alloca? Also assume for this example that for some reason I want for the value to be allocated on the stack