Re:Malloc Never Fails (2012)
by klodolph on Monday June 10, 2019 @09:17AM
(#20146428)
The space IS allocated, it's just that this space (virtual memory) is not backed by physical RAM.
[ Parent
| on HN ]
Try telling that to the C standard. It has no notion of virtual or physical memory. If it's allocated that means you can read/write to it, end of story.
> It has no notion of virtual or physical memory.
Exactly! That's why once virtual memory is allocated, malloc() is allowed to consider the operation successful. The standard does not care at all whether it is virtual memory allocation or physical memory allocation. It is completely unspecified in the standard what sort of memory must be allocated. So no spec in the standard is being violated by returning non-null pointer for virtual memory allocation.