What allocation do you prefer?
Like in “C” programming language, there are two types of allocation, just as we have it in life.
The one that is given to you by nature (automatic allocation),
The one you request/demand from nature (dynamic allocation).
Like in ‘C’ we always have the opportunity to take or be given.
Malloc function is your power in ‘C’ language to take the memory you want.
Malloc is used for dynamic memory allocation and is useful when you don't know the amount of memory needed during compile time. Allocating memory allows objects to exist beyond the scope of the current block.
And remember, after you have taken all you want from nature, it is compulsory to give back to society, because you could run out and crash for holding back.
In C language it is called the free function;
The free() function in C is used to free or deallocate the dynamically allocated memory and helps in reducing memory wastage.
This is how we make things work.