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 |
can we access one file to one directory?
How can I sort more data than will fit in memory?
what are the various memory handling mechanisms in C ?
Can we change the value of #define in c?
Explain what is wrong with this program statement? Void = 10;
What are the types of unary operators?
how can we use static and extern?and where can we use this?
How do you search data in a data file using random access method?
what is ANSI and ISO
What is clrscr in c?
Why c++ is called c++ and not c+?
How to find the usage of memory in a c program