I have been called on to write a "Partial Free" function for previously allocated virtual memory. EG, someone allocated a large block of memory with mmap(), and now they want to free a section *out of the middle or end* of it.
My reading of the POSIX munmap doc https://pubs.opengroup.org/onlinepubs/7908799/xsh/munmap.html is that munmap does this already, because it deallocates "pages" not previous allocations, and I only need to call munmap() with the requested-deallocated range (assuming the range to be page-aligned)
Correct?
@mcc That is also my understanding, and what I recall is also the implementation in various kernel sources (including Linux). mmap is not malloc, operates on independent pages, and munmap is not required to use only values returned by a previous mmap. You can even munmap pages which were present at process launch, and never explicitly mmap'd.