cheats: null checks on functions
All other cheat functions guard against the case where a null handle is passed. Adding checks to these functions makes behavior consistent all across the 'board'.
This commit is contained in:
parent
606eaa59ae
commit
244bb26972
9
cheats.c
9
cheats.c
|
@ -35,6 +35,9 @@ void cheat_manager_apply_cheats(cheat_manager_t *handle)
|
||||||
{
|
{
|
||||||
unsigned i, idx = 0;
|
unsigned i, idx = 0;
|
||||||
|
|
||||||
|
if (!handle)
|
||||||
|
return;
|
||||||
|
|
||||||
pretro_cheat_reset();
|
pretro_cheat_reset();
|
||||||
|
|
||||||
for (i = 0; i < handle->size; i++)
|
for (i = 0; i < handle->size; i++)
|
||||||
|
@ -185,6 +188,9 @@ bool cheat_manager_realloc(cheat_manager_t *handle, unsigned new_size)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
if (!handle)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!handle->cheats)
|
if (!handle->cheats)
|
||||||
handle->cheats = (struct item_cheat*)
|
handle->cheats = (struct item_cheat*)
|
||||||
calloc(new_size, sizeof(struct item_cheat));
|
calloc(new_size, sizeof(struct item_cheat));
|
||||||
|
@ -236,6 +242,9 @@ void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx)
|
||||||
{
|
{
|
||||||
char msg[256];
|
char msg[256];
|
||||||
|
|
||||||
|
if (!handle)
|
||||||
|
return;
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "Cheat: #%u [%s]: %s",
|
snprintf(msg, sizeof(msg), "Cheat: #%u [%s]: %s",
|
||||||
handle_idx, handle->cheats[handle_idx].state ? "ON" : "OFF",
|
handle_idx, handle->cheats[handle_idx].state ? "ON" : "OFF",
|
||||||
(handle->cheats[handle_idx].desc) ?
|
(handle->cheats[handle_idx].desc) ?
|
||||||
|
|
Loading…
Reference in New Issue