-
Free store vs. heap
I've been going through some tutorials and a book on C++ and in some, there is an interchange between the heap and free store terminology. One of them, however, says that they are not the same thing. It suggests that the free store is used in C++ and memory is allocated and freed using NEW and DELETE, whilst the heap is used in C and memory is allocated and freed using MALLOC and FREE. I am not familiar with the latter keywords as I have no experience of C, having decided to jump straight into C++.
Are the free store and heap interchangeable or are the distinctions mentioned above correct? If they are correct, I assume that keywords can't be mixed i.e. memory can't be allocated with MALLOC and freed with DELETE or allocated with NEW and freed with FREE?
-
> Are the free store and heap interchangeable or are the distinctions mentioned above correct?
Pretty much the same thing as far as I'm concerned.
New (c++) can be thought of as calling malloc (c), followed by calling appropriate constructors. Indeed in some systems this is how it is implemented.
In pretty much every system, both end up calling some base level "get memory from the OS and allocate as needed" type of memory pool management.
> I assume that keywords can't be mixed
Correct.