From: Pasi Kallinen Date: Tue, 23 Aug 2022 11:39:39 +0000 (+0300) Subject: Clear or copy whole selectionvar X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4cfefb056a14a604cf4242a0c6bc83bbdeacc45f;p=nethack Clear or copy whole selectionvar --- diff --git a/src/nhlsel.c b/src/nhlsel.c index 5f5a3b061..526920733 100644 --- a/src/nhlsel.c +++ b/src/nhlsel.c @@ -92,8 +92,7 @@ l_selection_push(lua_State *L) luaL_getmetatable(L, "selection"); lua_setmetatable(L, -2); - sel->wid = tmp->wid; - sel->hei = tmp->hei; + *sel = *tmp; sel->map = dupstr(tmp->map); selection_free(tmp, TRUE); @@ -120,9 +119,8 @@ l_selection_clone(lua_State *L) tmp = l_selection_check(L, 2); if (tmp->map) free(tmp->map); + *tmp = *sel; tmp->map = dupstr(sel->map); - tmp->wid = sel->wid; - tmp->hei = sel->hei; return 1; } diff --git a/src/sp_lev.c b/src/sp_lev.c index e6805c305..9f3e3aa67 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -4381,7 +4381,7 @@ selection_free(struct selectionvar* sel, boolean freesel) if (freesel) free((genericptr_t) sel); else - sel->wid = sel->hei = 0; + (void) memset((genericptr_t) sel, 0, sizeof *sel); } } @@ -4390,8 +4390,7 @@ selection_clone(struct selectionvar* sel) { struct selectionvar *tmps = (struct selectionvar *) alloc(sizeof *tmps); - tmps->wid = sel->wid; - tmps->hei = sel->hei; + *tmps = *sel; tmps->map = dupstr(sel->map); return tmps;