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 |
How can I manipulate strings of multibyte characters?
What is hash table in c?
shorting algorithmS
Is c functional or procedural?
What is a far pointer?What is the utility?
How can I list all of the predefined identifiers?
What is time null in c?
Name the language in which the compiler of "c" in written?
What the different types of arrays in c?
how to print "hai" in c?
How does struct work in c?
What is a class c rental property?