diff options
author | zeromus <zeromus@users.noreply.github.com> | 2022-08-24 05:01:11 +0300 |
---|---|---|
committer | zeromus <zeromus@users.noreply.github.com> | 2022-08-24 05:01:29 +0300 |
commit | ff633d5acd33ff4ea326cdd1a6743cb663264d92 (patch) | |
tree | 0f5649e6e04f8253c0fe8146182fe1c5e7fe37e3 | |
parent | 96e570ae445a3a4cd06f95419e35ba530d59f81a (diff) |
add new function FCEU_abort() for calling abort() with a message; use it when memory allocation fails instead of exit()
-rw-r--r-- | src/utils/memory.cpp | 11 | ||||
-rw-r--r-- | src/utils/memory.h | 3 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/utils/memory.cpp b/src/utils/memory.cpp index c261cbf3..93bc3af9 100644 --- a/src/utils/memory.cpp +++ b/src/utils/memory.cpp @@ -42,10 +42,7 @@ static void *_FCEU_malloc(uint32 size) #endif if(!ret) - { - FCEU_PrintError("Error allocating memory! Doing a hard exit."); - exit(1); - } + FCEU_abort("Error allocating memory!"); return ret; } @@ -98,3 +95,9 @@ void FCEU_dfree(void *ptr) { return FCEU_free(ptr); } + +void FCEU_abort(const char* message)
+{
+ if(message) FCEU_PrintError(message); + abort(); +}
diff --git a/src/utils/memory.h b/src/utils/memory.h index 174b3d31..b9e6f145 100644 --- a/src/utils/memory.h +++ b/src/utils/memory.h @@ -42,3 +42,6 @@ void *FCEU_dmalloc(uint32 size); //don't use these. change them if you find them. void FCEU_dfree(void *ptr); + +//aborts the process for fatal errors +void FCEU_abort(const char* message = nullptr); |