release wish history memory
The memory leak only happened at end of game so wasn't a big deal.
This commit is contained in:
17
src/zap.c
17
src/zap.c
@@ -6240,13 +6240,28 @@ wish_history_add(char *buf)
|
||||
|
||||
if (wish_history[idx])
|
||||
free(wish_history[idx]);
|
||||
wish_history[idx] = (char *)alloc(strlen(buf) + 1);
|
||||
wish_history[idx] = (char *) alloc(strlen(buf) + 1);
|
||||
strcpy(wish_history[idx], buf);
|
||||
wish_history_idx = (wish_history_idx + 1) % MAX_WISH_HISTORY;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
/* release any old wish text; called from freedynamicdata(save.c) */
|
||||
void
|
||||
wish_history_flush(void)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
int idx;
|
||||
|
||||
for (idx = 0; idx < MAX_WISH_HISTORY; ++idx) {
|
||||
if (wish_history[idx])
|
||||
free((genericptr_t) wish_history[idx]), wish_history[idx] = NULL;
|
||||
}
|
||||
wish_history_idx = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* shows menu of previous wishes, copies selected into buf, max BUFSZ len.
|
||||
buf is not modified, if nothing was selected. */
|
||||
staticfn void
|
||||
|
||||
Reference in New Issue
Block a user