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 |
write a c program to calculate the income tax of the employees in an organization where the conditions are given as. (I.T. = 0 if income <100000 I.T = 10% if income _< 200000 it = 20% if income >_ 200000)
7 Answers Consultancy, DBU, FD, JK Associates, Kobe, Satyam,
what is the difference b/w compiler and debugger?
Why main is used in c?
can we change the default calling convention in c if yes than how.........?
what will be the output for the following program? main() { char ch = 'k'; char c; printf("%c",c); }
Explain how can you check to see whether a symbol is defined?
inline function is there in c language?
If we give two names then this displays the connection between the two people. It is nothing but flames game
Write a program to generate prime factors of a given integer?
what is a void pointer?
how to find anagram without using string functions using only loops in c programming
how c source file in converted to exe file