From 1112ee24a3979ba655f2b4569f1d199dadd886fe Mon Sep 17 00:00:00 2001 From: mrdotK Date: Fri, 4 Feb 2022 23:00:18 -0500 Subject: [PATCH] vmem_mmap.c : add function vmem_mmap_top_free add function vmem_mmap_top_free for future . Signed-off-by: mrdotK --- vmem_mmap.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/vmem_mmap.c b/vmem_mmap.c index 6cf0d07..ac0a5f9 100644 --- a/vmem_mmap.c +++ b/vmem_mmap.c @@ -94,6 +94,19 @@ vmem_mmap_free(vmem_t *src, void *addr, size_t size) errno = old_errno; } +static void +vmem_mmap_top_free(vmem_t *src, void *addr, size_t size) +{ + int old_errno = errno; +#ifdef _WIN32 + VirtualFree(addr, size, MEM_RELEASE); +#else + (void) mmap(addr, size, FREE_PROT, FREE_FLAGS | MAP_FIXED, -1, 0); +#endif + vmem_free(src, addr, size); + errno = old_errno; +} + static void * vmem_mmap_top_alloc(vmem_t *src, size_t size, int vmflags) { -- 2.45.2