X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bdeck_id%7D%7D/cards/%7B%7Bcard_id%7D%7D/static/git-logo.png?a=blobdiff_plain;f=roguelike.c;h=6d75aa949ae181b5afd9ac783874905fde314d17;hb=e8f215126791c763c3168b9bb9083294a42b606c;hp=ee5dbe48be76fa54e3e9f7cafd2993a0c13404d6;hpb=ddf0e5d24690e9985c51d9960e035ee21286dd49;p=plomrogue diff --git a/roguelike.c b/roguelike.c index ee5dbe4..6d75aa9 100644 --- a/roguelike.c +++ b/roguelike.c @@ -218,7 +218,7 @@ void draw_keys_window (struct Win * win) { attr_t attri; int y, x; char * keyname; - for (y = 0; 0 != keybindings[offset + y].name && y < win->height; y++) { + for (y = 0; y <= keyswindata->max && y < win->height; y++) { attri = 0; if (y == keyswindata->select - offset) { attri = A_REVERSE; @@ -262,7 +262,7 @@ void init_keybindings(struct World * world) { c = getc(file); while (EOF != c) { if ('\n' == c) { - keybindings[keycount].name = calloc(commcount, sizeof(char)); + keybindings[keycount].name = calloc(commcount + 1, sizeof(char)); memcpy(keybindings[keycount].name, command, commcount); keybindings[keycount].key = key; keycount++; @@ -416,5 +416,13 @@ int main () { update_info (&win_info); update_log (&win_log, "\nYou wait."); } } + free(map.cells); + for (key = 0; key <= world.keyswindata->max; key++) + free(world.keybindings[key].name); + free(world.keybindings); + free(world.keyswindata); + free(win_info.data); + free(win_log.data); + endwin(); return 0; }