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 depending on the arch, the protections may be a finite resource, particularly embedded riscv.
So splitting a range, and then adding a new protection range may fail, I don't know how important that is in your environment, but there's not necessarily a guarantee that the "partial free" is possible.