Re:Malloc Never Fails (2012)
by klodolph on Monday June 10, 2019 @09:12AM
(#20146386)
Allocated "space", i.e., virtual memory space. Malloc allocates virtual memory space, not physical RAM.
[ Parent
| on HN ]
C has no notion of virtual memory. If memory is allocated for you that means you can read and write to it.
There is no guarantee offered by the standard that you must be able to read and write to memory allocated by malloc(). What if the memory was allocated and just a split second later, the physical RAM burnt out due to overheating? How is the standard supposed to guarantee reading and writing to it then?
Both the hardware burning after memory allocation and lack of availability of physical memory after memory allocation are outside the scope of the standard. The standard says nothing about them. A C program can fail in these scenarios without violating the standard.