summaryrefslogtreecommitdiffstats
path: root/Source/WTF/wtf/OSAllocatorWin.cpp
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WTF/wtf/OSAllocatorWin.cpp
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WTF/wtf/OSAllocatorWin.cpp')
-rw-r--r--Source/WTF/wtf/OSAllocatorWin.cpp20
1 files changed, 19 insertions, 1 deletions
diff --git a/Source/WTF/wtf/OSAllocatorWin.cpp b/Source/WTF/wtf/OSAllocatorWin.cpp
index 78300dc71..6a457f423 100644
--- a/Source/WTF/wtf/OSAllocatorWin.cpp
+++ b/Source/WTF/wtf/OSAllocatorWin.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2014 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -65,6 +65,16 @@ void OSAllocator::commit(void* address, size_t bytes, bool writable, bool execut
void OSAllocator::decommit(void* address, size_t bytes)
{
+ // According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx,
+ // bytes (i.e. dwSize) being 0 when dwFreeType is MEM_DECOMMIT means that we'll
+ // decommit the entire region allocated by VirtualAlloc() instead of decommitting
+ // nothing as we would expect. Hence, we should check if bytes is 0 and handle it
+ // appropriately before calling VirtualFree().
+ // See: https://bugs.webkit.org/show_bug.cgi?id=121972.
+ if (!bytes)
+ return;
+ // Silence warning about using MEM_DECOMMIT instead of MEM_RELEASE:
+#pragma warning(suppress: 6250)
bool result = VirtualFree(address, bytes, MEM_DECOMMIT);
if (!result)
CRASH();
@@ -72,6 +82,10 @@ void OSAllocator::decommit(void* address, size_t bytes)
void OSAllocator::releaseDecommitted(void* address, size_t bytes)
{
+ // See comment in OSAllocator::decommit(). Similarly, when bytes is 0, we
+ // don't want to release anything. So, don't call VirtualFree() below.
+ if (!bytes)
+ return;
// According to http://msdn.microsoft.com/en-us/library/aa366892(VS.85).aspx,
// dwSize must be 0 if dwFreeType is MEM_RELEASE.
bool result = VirtualFree(address, 0, MEM_RELEASE);
@@ -79,6 +93,10 @@ void OSAllocator::releaseDecommitted(void* address, size_t bytes)
CRASH();
}
+void OSAllocator::hintMemoryNotNeededSoon(void*, size_t)
+{
+}
+
} // namespace WTF
#endif // OS(WINDOWS)