vmem_mmap.c : add function vmem_mmap_top_free

add function vmem_mmap_top_free for future .

Signed-off-by: mrdotK <ldys2014@foxmail.com>
This commit is contained in:
mrdotK 2022-02-04 23:00:18 -05:00
parent c4b96af829
commit 1112ee24a3

View file

@ -94,6 +94,19 @@ vmem_mmap_free(vmem_t *src, void *addr, size_t size)
errno = old_errno; 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 * static void *
vmem_mmap_top_alloc(vmem_t *src, size_t size, int vmflags) vmem_mmap_top_alloc(vmem_t *src, size_t size, int vmflags)
{ {