Does anyone know why mmap () returns MAP_FAILED instead of NULL? MAP_FAILED (void *) seems to be 1 on most systems. Why is null used instead of mmap ()? I know that address 0x0 is a technically valid memory page, whereas (void *) - 1 will never be a valid page. However, I assume that mmap () will never return a 0x0 page in practice. On Windows, for example, VirtualAlloc () returns NULL on error.
Can we assume that mmap () will never return 0x0? Presumably, a successful mmap () call should return useful memory to the caller. Address 0x0 is never used, so it should never be returned after success. This would make it reasonable to use 0x0 as a failure-loser, so I am puzzled by the existence of MAP_FAILED in the first place.
source share