The mmap
man page on my mac says the following
The mmap() system call causes the pages starting at addr and continuing for at most len bytes to be mapped from the object described by fd, starting at byte offset offset.
Does this mean that the call can fail without an error and return a portion of memory mapped to an address range that is smaller than what was asked for?
For example if I do the following
void* memory = mmap(nullptr, range, PROT_READ | PROT_WRITE, MAP_ANONYMOUS, -1, 0);
Then can the call succeed without an error and return an address range that is not range
bytes long?
The "address range" will still be
range
bytes long (or possibly longer if you haven't aligned things properly), but may not be mapped.len + offset
may extend past the end of the mapped object (for example, past the end of a file). If that occurs, then the docs indicate "any extension beyond the end of the mapped object will be zero-filled."