+ 5

Why malloc() allocates memory from heap not from stack?How?

29th Jan 2019, 4:24 PM
Pilla Bhumika Rajya Lakshmi
2 Answers
+ 3
Stack memory is occupied with function calls. It might be difficult to allocate memory from stack
29th Jan 2019, 5:01 PM
Vinnakota Moulidhar
Vinnakota Moulidhar - avatar
+ 2
The stack is very limited in comparison to the heap. And allocating memory from the stack means a danger of stack-overflow, and the possibility to execute shellcodes easier.
29th Jan 2019, 8:04 PM
Théophile
Théophile - avatar