Reputation: 15752
for what do we actually require manual storage allocation?
The only possible tasks which I could think about would be for bigger binary data which does not fit to a 32bit integer.
Is this correct? What are other use cases?
Upvotes: 2
Views: 147
Reputation: 726609
In general, you need to do manual storage allocation every time that the size of your data is not known at compile time. Almost all situations fall into two categories:
Many very common data structures assume an ability to allocate memory of arbitrary size, when the precise size is determined at runtime. Doing so lets the data structure "grow" and "shrink" dynamically, as the storage demands of your program change with the time and the amounts of data that it processes.
Upvotes: 1
Reputation: 4102
tons of examples. Allocating memory to fill a struct, for example, a linked list struct.
Upvotes: 0