cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
whats malloc good for in "real" programm
whats malloc good for in "real" programming?
Nov 24, 2011 at 2:42pm UTC
Blessman11
(370)
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?
Nov 24, 2011 at 3:07pm UTC
Peter87
(11234)
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.
Nov 24, 2011 at 3:27pm UTC
Cubbi
(4774)
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
Nov 24, 2011 at 3:33pm UTC
Topic archived. No new replies allowed.