mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-22 17:05:22 +00:00
Fix crashes on Symbian related to memory allocation.
This commit is contained in:
parent
53800bd413
commit
3bc8adf426
@ -635,7 +635,9 @@ public:
|
||||
// Call this when shutting down. Don't rely on the destructor, even though it'll do the job.
|
||||
void FreeCodeSpace()
|
||||
{
|
||||
#ifndef __SYMBIAN32__
|
||||
#ifdef __SYMBIAN32__
|
||||
FreeExecutableMemory(region);
|
||||
#else
|
||||
FreeMemoryPages(region, region_size);
|
||||
#endif
|
||||
region = NULL;
|
||||
|
@ -45,10 +45,16 @@
|
||||
|
||||
#ifdef __SYMBIAN32__
|
||||
#include <e32std.h>
|
||||
#define SYMBIAN_CODECHUNK_SIZE 1024*1024*20;
|
||||
#define CODECHUNK_SIZE 1024*1024*20
|
||||
static RChunk* g_code_chunk = NULL;
|
||||
static RHeap* g_code_heap = NULL;
|
||||
static void* g_next_ptr = NULL;
|
||||
static u8* g_next_ptr = NULL;
|
||||
|
||||
void FreeExecutableMemory(void* ptr)
|
||||
{
|
||||
// Just reset the ptr to the base
|
||||
g_next_ptr = g_orig_ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
// This is purposely not a full wrapper for virtualalloc/mmap, but it
|
||||
@ -63,14 +69,13 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
||||
//memory chunk for all the executable code for the JIT
|
||||
if( g_code_chunk == NULL && g_code_heap == NULL)
|
||||
{
|
||||
TInt minsize = SYMBIAN_CODECHUNK_SIZE;
|
||||
TInt maxsize = SYMBIAN_CODECHUNK_SIZE + 3*GetPageSize(); //some offsets
|
||||
g_code_chunk = new RChunk();
|
||||
g_code_chunk->CreateLocalCode(minsize, maxsize);
|
||||
g_code_heap = UserHeap::ChunkHeap(*g_code_chunk, minsize, 1, maxsize);
|
||||
g_next_ptr = (void*) g_code_heap->Alloc( minsize );
|
||||
g_code_chunk->CreateLocalCode(CODECHUNK_SIZE, CODECHUNK_SIZE + 3*GetPageSize());
|
||||
g_code_heap = UserHeap::ChunkHeap(*g_code_chunk, CODECHUNK_SIZE, 1, CODECHUNK_SIZE + 3*GetPageSize());
|
||||
g_next_ptr = reinterpret_cast<u8*>(g_code_heap->AllocZ(CODECHUNK_SIZE));
|
||||
g_orig_ptr = g_next_ptr;
|
||||
}
|
||||
void* ptr = g_next_ptr;
|
||||
void* ptr = (void*)g_next_ptr;
|
||||
g_next_ptr += size;
|
||||
#else
|
||||
static char *map_hint = 0;
|
||||
@ -123,7 +128,7 @@ void* AllocateMemoryPages(size_t size)
|
||||
#ifdef _WIN32
|
||||
void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
||||
#elif defined(__SYMBIAN32__)
|
||||
void* ptr = new u8[size];
|
||||
void* ptr = malloc(size);
|
||||
#else
|
||||
void* ptr = mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
|
||||
#endif
|
||||
@ -173,7 +178,7 @@ void FreeMemoryPages(void* ptr, size_t size)
|
||||
PanicAlert("FreeMemoryPages failed!\n%s", GetLastErrorMsg());
|
||||
ptr = NULL; // Is this our responsibility?
|
||||
#elif defined(__SYMBIAN32__)
|
||||
delete [] ptr;
|
||||
free(ptr);
|
||||
#else
|
||||
munmap(ptr, size);
|
||||
#endif
|
||||
|
@ -30,6 +30,9 @@ void* AllocateAlignedMemory(size_t size,size_t alignment);
|
||||
void FreeAlignedMemory(void* ptr);
|
||||
void WriteProtectMemory(void* ptr, size_t size, bool executable = false);
|
||||
void UnWriteProtectMemory(void* ptr, size_t size, bool allowExecute = false);
|
||||
#ifdef __SYMBIAN32__
|
||||
void FreeExecutableMemory(void* ptr);
|
||||
#endif
|
||||
|
||||
inline int GetPageSize() { return 4096; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user