whats malloc good for in "real" programming?

Whats malloc good for ? is it good when you know exactly whats going to be in memory constantly as your programming is being executed?

Is it like declaring volatile for unknown code you want make sure is always attended to?
malloc is a leftover form C and is rarely used in C++. In C++ we use new instead because it is type safe and call constructors and such nice things.
malloc() is good for obtaining uninitialized storage, e.g. when preparing a memory pool which will hold multiple objects of various unrelated types. Especially if the pool may have to be resized later on.
Last edited on
Topic archived. No new replies allowed.