From d51551f3032ef08e8d29506b2230a70cf948bb53 Mon Sep 17 00:00:00 2001 From: Aaron Giles Date: Mon, 11 Jan 2010 02:37:17 +0000 Subject: [PATCH] Fix cheat crash and comment display. --- src/emu/cheat.c | 6 ++++-- src/emu/uimenu.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/emu/cheat.c b/src/emu/cheat.c index 2e1d7628c60..b4a6bdc36cb 100644 --- a/src/emu/cheat.c +++ b/src/emu/cheat.c @@ -193,7 +193,7 @@ struct _cheat_entry script_state state; /* current cheat state */ UINT32 numtemp; /* number of temporary variables */ UINT64 argindex; /* argument index variable */ - UINT64 tempvar[1]; /* value of the temporary variables */ + UINT64 * tempvar; /* value of the temporary variables */ }; @@ -1177,7 +1177,8 @@ static cheat_entry *cheat_entry_load(running_machine *machine, const char *filen } /* allocate memory for the cheat */ - cheat = (cheat_entry *)auto_alloc_array_clear(machine, UINT8, sizeof(*cheat) + (tempcount - 1) * sizeof(cheat->tempvar)); + cheat = auto_alloc_clear(machine, cheat_entry); + cheat->tempvar = auto_alloc_array_clear(machine, UINT64, tempcount); cheat->numtemp = tempcount; /* get the description */ @@ -1324,6 +1325,7 @@ static void cheat_entry_free(running_machine *machine, cheat_entry *cheat) if (cheat->symbols != NULL) symtable_free(cheat->symbols); + auto_free(machine, cheat->tempvar); auto_free(machine, cheat); } diff --git a/src/emu/uimenu.c b/src/emu/uimenu.c index addecf7d55e..7ab40c1dce8 100644 --- a/src/emu/uimenu.c +++ b/src/emu/uimenu.c @@ -2533,7 +2533,7 @@ static void menu_cheat(running_machine *machine, ui_menu *menu, void *parameter, case IPT_UI_DISPLAY_COMMENT: case IPT_UI_UP: case IPT_UI_DOWN: - if (cheat_get_comment(event->itemref) != NULL) + if (cheat_get_comment(event->itemref).len() != 0) popmessage("Cheat Comment:\n%s", cheat_get_comment(event->itemref).cstr()); break; }