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 |
What is a static variable in c?
What is the difference between exit() and _exit() function?
how can be easily placed in TCS.
difference between ordinary variable and pointer in C?
Differentiate between declaring a variable and defining a variable?
why return type of main is not necessary in linux
Explain the differences between public, protected, private and internal.
Is array a primitive data type in c?
write a program to sum of its digit with using control structure or with out using loop. for ex: let the number is 25634 then answer will be=2+5+6+3+4=20
identify the in correct expression a.a=b=3=4; b.a=b=c=d=0; float a=int b=3.5; d.int a; float b; a=b=3.5;
what is data structure
how to introdu5ce my self in serco