summaryrefslogtreecommitdiff
path: root/src/common/memory_util.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/memory_util.cpp')
-rw-r--r--src/common/memory_util.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/common/memory_util.cpp b/src/common/memory_util.cpp
index e1cd6e553..e01e63175 100644
--- a/src/common/memory_util.cpp
+++ b/src/common/memory_util.cpp
@@ -51,14 +51,14 @@ void* AllocateExecutableMemory(size_t size, bool low)
51 // printf("Mapped executable memory at %p (size %ld)\n", ptr, 51 // printf("Mapped executable memory at %p (size %ld)\n", ptr,
52 // (unsigned long)size); 52 // (unsigned long)size);
53 53
54#if defined(__FreeBSD__) 54#ifdef _WIN32
55 if (ptr == MAP_FAILED) 55 if (ptr == nullptr)
56 { 56 {
57 ptr = NULL;
58#else 57#else
59 if (ptr == NULL) 58 if (ptr == MAP_FAILED)
60 { 59 {
61#endif 60 ptr = nullptr;
61#endif
62 PanicAlert("Failed to allocate executable memory"); 62 PanicAlert("Failed to allocate executable memory");
63 } 63 }
64#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT) 64#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
@@ -88,6 +88,9 @@ void* AllocateMemoryPages(size_t size)
88#else 88#else
89 void* ptr = mmap(0, size, PROT_READ | PROT_WRITE, 89 void* ptr = mmap(0, size, PROT_READ | PROT_WRITE,
90 MAP_ANON | MAP_PRIVATE, -1, 0); 90 MAP_ANON | MAP_PRIVATE, -1, 0);
91
92 if (ptr == MAP_FAILED)
93 ptr = nullptr;
91#endif 94#endif
92 95
93 // printf("Mapped memory at %p (size %ld)\n", ptr, 96 // printf("Mapped memory at %p (size %ld)\n", ptr,