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

Why #include is used in c language?

602


What is array in c with example?

617


C language questions for civil engineering

1245


What is void c?

569


Is null a keyword in c?

737






Write a program to check palindrome number in c programming?

601


What is bubble sort in c?

640


What is sizeof array in c?

596


What is table lookup in c?

632


how can f be used for both float and double arguments in printf? Are not they different types?

610


What is the value of h?

593


What is memory leak in c?

638


What is static volatile in c?

576


Why void main is used in c?

560


Is linux written in c?

602