Fix valgrind complaints of uninitialized memory

This commit is contained in:
Pasi Kallinen
2016-05-23 16:21:36 +03:00
parent bc91a01fdd
commit e37da61b30
6 changed files with 7 additions and 1 deletions

View File

@@ -490,6 +490,7 @@ struct proto_dungeon *pd;
branch_num = find_branch(dungeons[dgn].dname, pd);
new_branch = (branch *) alloc(sizeof(branch));
(void) memset((genericptr_t)new_branch, 0, sizeof(branch));
new_branch->next = (branch *) 0;
new_branch->id = branch_id++;
new_branch->type = correct_branch_type(&pd->tmpbranch[branch_num]);
@@ -545,6 +546,7 @@ struct proto_dungeon *pd;
pd->final_lev[proto_index] = new_level =
(s_level *) alloc(sizeof(s_level));
(void) memset((genericptr_t)new_level, 0, sizeof(s_level));
/* load new level with data */
Strcpy(new_level->proto, tlevel->name);
new_level->boneid = tlevel->boneschar;

View File

@@ -388,6 +388,7 @@ xchar e_type;
if ((ep = engr_at(x, y)) != 0)
del_engr(ep);
ep = newengr(strlen(s) + 1);
(void) memset((genericptr_t)ep, 0, sizeof(struct engr));
ep->nxt_engr = head_engr;
head_engr = ep;
ep->engr_x = x;

View File

@@ -2516,7 +2516,7 @@ struct obj *no_wish;
int halfeaten, mntmp, contents;
int islit, unlabeled, ishistoric, isdiluted, trapped;
int tmp, tinv, tvariety;
int wetness, gsize;
int wetness, gsize = 0;
struct fruit *f;
int ftype = context.current_fruit;
char fruitbuf[BUFSZ];

View File

@@ -5496,6 +5496,7 @@ struct fruit *replace_fruit;
return rnd(127);
f = newfruit();
(void) memset((genericptr_t)f, 0, sizeof(struct fruit));
copynchars(f->fname, *altname ? altname : str, PL_FSIZ - 1);
f->fid = ++highest_fruit_id;
/* we used to go out of our way to add it at the end of the list,

View File

@@ -1533,6 +1533,7 @@ anything *arg;
panic("start_timer");
gnu = (timer_element *) alloc(sizeof(timer_element));
(void) memset((genericptr_t)gnu, 0, sizeof(timer_element));
gnu->next = 0;
gnu->tid = timer_id++;
gnu->timeout = monstermoves + when;

View File

@@ -337,6 +337,7 @@ int x, y, typ;
} else {
oldplace = FALSE;
ttmp = newtrap();
(void) memset((genericptr_t)ttmp, 0, sizeof(struct trap));
ttmp->ntrap = 0;
ttmp->tx = x;
ttmp->ty = y;