Why the use of alloca() is discouraged?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

722


What is the argument of a function in c?

569


Is python a c language?

550


What is static identifier?

701


all c language question

1864






What does typedef struct mean?

654


Explain how can a program be made to print the name of a source file where an error occurs?

682


Explain what is the benefit of using #define to declare a constant?

604


Write a program to swap two numbers without using third variable in c?

613


What is the difference between ++a and a++?

688


In which language linux is written?

595


What is the purpose of 'register' keyword in c language?

625


How pointer is different from array?

573


Can variables be declared anywhere in c?

615


Give me the code of in-order recursive and non-recursive.

882