mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 16:22:47 +01:00
Merge pull request #52 from lioncash/memory
Common: Correctly set ptr to null if mmap fails in memory_util
This commit is contained in:
commit
68c81f28d9
1 changed files with 9 additions and 6 deletions
|
@ -51,14 +51,14 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
||||||
// printf("Mapped executable memory at %p (size %ld)\n", ptr,
|
// printf("Mapped executable memory at %p (size %ld)\n", ptr,
|
||||||
// (unsigned long)size);
|
// (unsigned long)size);
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
#ifdef _WIN32
|
||||||
|
if (ptr == nullptr)
|
||||||
|
{
|
||||||
|
#else
|
||||||
if (ptr == MAP_FAILED)
|
if (ptr == MAP_FAILED)
|
||||||
{
|
{
|
||||||
ptr = NULL;
|
ptr = nullptr;
|
||||||
#else
|
#endif
|
||||||
if (ptr == NULL)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
PanicAlert("Failed to allocate executable memory");
|
PanicAlert("Failed to allocate executable memory");
|
||||||
}
|
}
|
||||||
#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
|
#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
|
||||||
|
@ -88,6 +88,9 @@ void* AllocateMemoryPages(size_t size)
|
||||||
#else
|
#else
|
||||||
void* ptr = mmap(0, size, PROT_READ | PROT_WRITE,
|
void* ptr = mmap(0, size, PROT_READ | PROT_WRITE,
|
||||||
MAP_ANON | MAP_PRIVATE, -1, 0);
|
MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||||
|
|
||||||
|
if (ptr == MAP_FAILED)
|
||||||
|
ptr = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// printf("Mapped memory at %p (size %ld)\n", ptr,
|
// printf("Mapped memory at %p (size %ld)\n", ptr,
|
||||||
|
|
Loading…
Reference in a new issue