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/gitweb.js?a=blobdiff_plain;f=src%2Fclient%2Fwindows.c;h=6bde9ef1ce2d5431e70bdabdb1680dd73038b320;hb=316a56901b2249264b72992fd5aa63ce16fd3304;hp=2d5dd3a37af6d7f2bfad189aaf0c68ffa329559f;hpb=024b404c0db59dc6651b1c8f3d379c2797654fdf;p=plomrogue diff --git a/src/client/windows.c b/src/client/windows.c index 2d5dd3a..6bde9ef 100644 --- a/src/client/windows.c +++ b/src/client/windows.c @@ -10,7 +10,7 @@ #include /* free(), atoi() */ #include /* uint8_t, uint16_t, uint32_t, UINT16_MAX */ #include /* sprintf() */ -#include /* memcpy(), strlen(), strnlen(), strchr() */ +#include /* memcpy(), strlen(), strnlen(), strchr(), memset() */ #include "../common/rexit.h" /* exit_trouble(), exit_err() */ #include "../common/readwrite.h" /* try_fputc(), try_write(), try_fgets(), * try_fgetc() @@ -483,10 +483,9 @@ static void draw_wins(struct Win * w) w->start.x + (x - offset_x), ch); } } - free(w->winmap); - w->winmap = NULL; - w->winmap_size.y = 0; - w->winmap_size.x = 0; + free(w->winmap); /* NULL so draw_wins.c's try_resize_winmap() may always */ + w->winmap = NULL;/* free() it before (re-)allocation, even the first time.*/ + memset(&w->winmap_size, 0, sizeof(struct yx_uint16)); if (offset_y > 0) { winscroll_hint(w, '^', offset_y + 1); @@ -631,6 +630,7 @@ extern uint8_t read_winconf_from_file(char * line, uint32_t linemax, return 0; } struct Win win; + memset(&win, 0, sizeof(struct Win)); win.id = (char) test; try_fgetc(file, f_name); try_fgets(line, linemax + 1, file, f_name); @@ -644,14 +644,6 @@ extern uint8_t read_winconf_from_file(char * line, uint32_t linemax, win.target_width = atoi(line); win.target_width_type = (0 >= win.target_width); read_keybindings_from_file(line, linemax, file, &win.kb); - win.view = 0; - win.target_center.y = 0; - win.target_center.x = 0; - win.winmap_size.y = 0; - win.winmap_size.x = 0; - win.winmap = NULL; - win.center.y = 0; - win.center.x = 0; add_win_to_windb(&win); return 1; } @@ -742,12 +734,10 @@ extern void free_windb() free(wc->title); free_keybindings(wc->kb.kbs); } - free(world.windb.ids); - world.windb.ids = NULL; + free(world.windb.ids); /* NULL this too since add_win_to_windb() checks */ + world.windb.ids = NULL; /* for it to detect its first post-DB-purge round.*/ free(world.windb.wins); - world.windb.wins = NULL; free(world.windb.order); - world.windb.order = NULL; } @@ -845,8 +835,7 @@ extern void toggle_winconfig() { w->view = 1; w->target_center = w->center; - w->center.y = 0; - w->center.x = 0; + memset(&w->center, 0, sizeof(struct yx_uint16)); return; } else if (1 == w->view)