diff options
Diffstat (limited to 'src/utils/memory.cpp')
-rw-r--r-- | src/utils/memory.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/utils/memory.cpp b/src/utils/memory.cpp index 5ed626ea..93bc3af9 100644 --- a/src/utils/memory.cpp +++ b/src/utils/memory.cpp @@ -30,19 +30,19 @@ static void *_FCEU_malloc(uint32 size) { + //do not add an aligned allocation function. if a larger alignment is needed, change this constant to use it for all allocations. + static const int alignment = 32; + + size = (size + alignment - 1) & ~(alignment-1); + #ifdef _MSC_VER - void *ret = _aligned_malloc(size,32); + void *ret = _aligned_malloc(size,alignment); #else - void *ret = aligned_alloc(32,size); + void *ret = aligned_alloc(alignment,size); #endif if(!ret) - { - FCEU_PrintError("Error allocating memory! Doing a hard exit."); - exit(1); - } - - memset(ret, 0, size); + FCEU_abort("Error allocating memory!"); return ret; } @@ -74,13 +74,13 @@ void *FCEU_malloc(uint32 size) return ret; } -///frees memory allocated with FCEU_gmalloc +//frees memory allocated with FCEU_gmalloc void FCEU_gfree(void *ptr) { _FCEU_free(ptr); } -///frees memory allocated with FCEU_malloc +//frees memory allocated with FCEU_malloc void FCEU_free(void *ptr) { _FCEU_free(ptr); @@ -95,3 +95,9 @@ void FCEU_dfree(void *ptr) { return FCEU_free(ptr); } + +void FCEU_abort(const char* message)
+{
+ if(message) FCEU_PrintError(message); + abort(); +}
|