int main() { assert(InitWrapper(4096) != NULL); assert(AllocWrapper(2048) != NULL); assert(AllocWrapper(2049) == NULL); exit(0); }
int main() { assert(InitWrapper(4096) != NULL); void* ptr[4]; ptr[0] = AllocWrapper(8); ptr[1] = AllocWrapper(16); assert(Mem_Free(ptr[0]) == 0); assert(Mem_Free(ptr[1]) == 0); ptr[2] = AllocWrapper(32); ptr[3] = AllocWrapper(8); assert(Mem_Free(ptr[2]) == 0); assert(Mem_Free(ptr[3]) == 0); exit(0); }
BYTE* WebAssemblySharedArrayBuffer::AllocBuffer(uint32 length, uint32 maxLength) { #if ENABLE_FAST_ARRAYBUFFER if (CONFIG_FLAG(WasmFastArray)) { return (BYTE*)WasmVirtualAllocator(length); } #endif #ifdef _WIN32 if (CONFIG_FLAG(WasmSharedArrayVirtualBuffer)) { return (BYTE*)AllocWrapper(length, maxLength); } #endif AssertOrFailFast(maxLength >= length); uint32 additionalSize = maxLength - length; if (additionalSize > 0) { // SharedArrayBuffer::Init already requested External Memory for `length`, we need to request the balance if (!this->GetRecycler()->RequestExternalMemoryAllocation(additionalSize)) { // Failed to request for more memory return nullptr; } } // Allocate the full size of the buffer if we can't do VirtualAlloc return HeapNewNoThrowArray(BYTE, maxLength); }
int main() { int i; assert(InitWrapper(40960) != NULL); void *ptr = AllocWrapper(1024); assert(ptr != NULL); void *tmp; while ((tmp = AllocWrapper(1)) != NULL) ; for (i=0; i<1000; i++) { Mem_Free(ptr); ptr = AllocWrapper(1024-i); assert(ptr != NULL); } exit(0); }
__cdecl operator new ( IN size_t size ) { return AllocWrapper(size); }