I have one doubt may be so many guys answer this.
We know that malloc use to allocate dynamic memory. But while writing programs we use to check with NULL.
If(p==NULL)printf(“mem alloction failed”);// <-----(When dynamic allocation fail)
1. When will memory allocation fail?
2. I have a scenario that it should not be fail at any cost for that what I should do?
> 1. When will memory allocation fail?
Typically when you run out of memory, or the pool has become too fragmented that no large blocks remain.
> 2. I have a scenario that it should not be fail at any cost for that what I should do?
So you're writing a safety critical system in C?
|All times are GMT +5.5. The time now is 19:52.|