Prevent crashes and hangs

This commit is contained in:
MysterD 2023-05-13 03:07:20 -07:00
parent 093754ae1b
commit 8129ab7665
6 changed files with 10 additions and 5 deletions

View file

@ -80,6 +80,7 @@ override_allowed_functions = {
override_disallowed_functions = { override_disallowed_functions = {
"src/audio/external.h": [ " func_" ], "src/audio/external.h": [ " func_" ],
"src/engine/math_util.h": [ "atan2s", "atan2f", "vec3s_sub" ], "src/engine/math_util.h": [ "atan2s", "atan2f", "vec3s_sub" ],
"src/engine/surface_load.h", [ "alloc_surface_poools" ],
"src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ], "src/engine/surface_collision.h": [ " debug_", "f32_find_wall_collision" ],
"src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ], "src/game/mario_actions_airborne.c": [ "^[us]32 act_.*" ],
"src/game/mario_actions_automatic.c": [ "^[us]32 act_.*" ], "src/game/mario_actions_automatic.c": [ "^[us]32 act_.*" ],

View file

@ -529,6 +529,9 @@ void alloc_surface_pools(void) {
gSurfaceNodesAllocated = 0; gSurfaceNodesAllocated = 0;
gSurfacesAllocated = 0; gSurfacesAllocated = 0;
clear_static_surfaces();
clear_dynamic_surfaces();
gCCMEnteredSlide = 0; gCCMEnteredSlide = 0;
reset_red_coins_collected(); reset_red_coins_collected();
} }

View file

@ -2002,11 +2002,6 @@ static u8 prevent_hang(u32 hangPreventionActions[], u8* hangPreventionIndex) {
logfile_close(LFT_HANG); logfile_close(LFT_HANG);
// force the crash in debug mode
#ifdef DEBUG
SOFT_ASSERT_RETURN(hangPreventionIndex == 0, TRUE);
#endif
return TRUE; return TRUE;
} }

View file

@ -628,6 +628,9 @@ void anim_and_audio_for_walk(struct MarioState *m) {
val0C = FALSE; val0C = FALSE;
} }
break; break;
default:
val0C = false;
break;
} }
} }
} }

View file

@ -25,6 +25,7 @@ void* dynamic_pool_alloc(struct DynamicPool *pool, u32 size) {
struct DynamicPoolNode* node = calloc(1, sizeof(struct DynamicPoolNode)); struct DynamicPoolNode* node = calloc(1, sizeof(struct DynamicPoolNode));
node->ptr = calloc(1, size); node->ptr = calloc(1, size);
node->prev = pool->tail; node->prev = pool->tail;
node->size = size;
pool->tail = node; pool->tail = node;
pool->usedSpace += size; pool->usedSpace += size;
@ -46,6 +47,7 @@ void dynamic_pool_free(struct DynamicPool *pool, void* ptr) {
} else { } else {
next->prev = prev; next->prev = prev;
} }
pool->usedSpace -= node->size;
free(node->ptr); free(node->ptr);
free(node); free(node);
return; return;

View file

@ -20,6 +20,7 @@ struct DynamicPool
struct DynamicPoolNode struct DynamicPoolNode
{ {
void* ptr; void* ptr;
u32 size;
struct DynamicPoolNode* prev; struct DynamicPoolNode* prev;
}; };