EXPORT BOOL VirtualFreeEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType) { mach_vm_address_t addr = (mach_vm_address_t) lpAddress; return virtual_free(hProcess, addr, dwSize); }
void pool_free_size(size_t size, void* p) { size_t index = pool_index(size); if(index < POOL_COUNT) return pool_free(index, p); virtual_free(p, size); #ifdef USE_VALGRIND VALGRIND_FREELIKE_BLOCK(p, 0); #endif }
//static INTERNAL_INTPTR_T munmap ( void *ptr, INTERNAL_INTPTR_T size) { #ifndef USE_PTMALLOC3_ARENA static INTERNAL_INTPTR_T g_pagesize; int rc = MUNMAP_FAILURE; #ifdef TRACE printf ("munmap %p %d\n", ptr, size); #endif /* Wait for spin lock */ /* slwait (&g_sl); */ /* First time initialization */ if (! g_pagesize) g_pagesize = getpagesize (); /* Assert preconditions */ assert (((INTERNAL_SIZE_T) ptr) % g_pagesize == 0); assert (size % g_pagesize == 0); /* Free this */ // if (! VirtualFree (ptr, 0, // MEM_RELEASE)) if (! VirtualAlloc (ptr, 0, MEM_RESERVE, PAGE_NOACCESS)) goto munmap_exit; rc = 0; #ifdef TRACE printf ("Release %p %d\n", ptr, size); #endif munmap_exit: /* Release spin lock */ /* slrelease (&g_sl); */ return rc; #else // #ifndef USE_PTMALLOC3_ARENA slwait ( &g_sl ); virtual_free( &g_ptmalloc3_arena, ptr, size ); slrelease ( &g_sl ); return ( 0 ); #endif // #ifndef USE_PTMALLOC3_ARENA }
EXPORT BOOL VirtualFreeEx(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType){ return virtual_free(hProcess, (int) lpAddress, dwSize); }