summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/wtf/PageAllocation.h
diff options
context:
space:
mode:
Diffstat (limited to 'JavaScriptCore/wtf/PageAllocation.h')
-rw-r--r--JavaScriptCore/wtf/PageAllocation.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/JavaScriptCore/wtf/PageAllocation.h b/JavaScriptCore/wtf/PageAllocation.h
index 26d53a5..c13821c 100644
--- a/JavaScriptCore/wtf/PageAllocation.h
+++ b/JavaScriptCore/wtf/PageAllocation.h
@@ -29,6 +29,7 @@
#include <wtf/Assertions.h>
#include <wtf/UnusedParam.h>
#include <wtf/VMTags.h>
+#include <algorithm>
#if OS(DARWIN)
#include <mach/mach_init.h>
@@ -266,9 +267,11 @@ inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, Usage u
inline void PageAllocation::systemDeallocate(bool)
{
- int result = munmap(m_base, m_size);
+ void* tmp = 0;
+ std::swap(tmp, m_base);
+
+ int result = munmap(tmp, m_size);
ASSERT_UNUSED(result, !result);
- m_base = 0;
}
inline size_t PageAllocation::systemPageSize()
@@ -303,14 +306,16 @@ inline PageAllocation PageAllocation::systemAllocateAligned(size_t size, Usage u
inline void PageAllocation::systemDeallocate(bool committed)
{
+ void* tmp = 0;
+ std::swap(tmp, m_base);
+
#if OS(WINCE)
if (committed)
- VirtualFree(m_base, m_size, MEM_DECOMMIT);
+ VirtualFree(tmp, m_size, MEM_DECOMMIT);
#else
UNUSED_PARAM(committed);
#endif
- VirtualFree(m_base, 0, MEM_RELEASE);
- m_base = 0;
+ VirtualFree(tmp, 0, MEM_RELEASE);
}
inline size_t PageAllocation::systemPageSize()
@@ -338,9 +343,11 @@ inline PageAllocation PageAllocation::systemAllocate(size_t size, Usage usage, b
inline void PageAllocation::systemDeallocate(bool)
{
+ void* tmp = 0;
+ std::swap(tmp, m_base);
+
m_chunk->Close();
delete m_chunk;
- m_base = 0;
}
inline size_t PageAllocation::systemPageSize()