Hi,
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.
Char *p;
p=(char *)malloc(100);
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?
|
Ambitious contributor
|
|
| 6Dec2007,15:11 | #2 |
|
> 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? |
