Why the use of alloca() is discouraged?
Answers were Sorted based on User's Feedback
Answer / johnson
Sorry, that is not strictly correct. According to the man page:
"The alloca() function allocates size bytes of space in the
stack frame of the caller, and returns a pointer to the
allocated block. This temporary space is automatically freed
when the caller returns."
Now this is the real reason:
" If the allocated block is beyond the current stack limit,
the resulting behavior is undefined."
| Is This Answer Correct ? | 12 Yes | 0 No |
Answer / sathish kumar
Hi All,
If you use alloca inside a function when it retuns from
function it will be resulting in memory leak. Thats why
its discouraged to use.
Thanks & Regards
Sathish Kumar
| Is This Answer Correct ? | 2 Yes | 5 No |
# define x=1+4; main() { int x; printf("%d%d",x/2,x/4); }
how to go with this?
Do pointers store the address of value or the actual value of a variable?
What is pointers in c with example?
Can we declare a function inside a function in c?
What is the difference between the = symbol and == symbol?
sir i got 146 correct question & i have also the advantage of height so will they consider my marks as 146+3=149.can any body tell me how they consider my height marks.
why arithmetic operation can’t be performed on a void pointer?
what is the output of below int n=10; (n++)++; printf("%d",n);
is it possible to change the default calling convention in c ?
What is the difference between malloc calloc and realloc in c?
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell