(svn r7522) -Codechange: Have CopyGRFConfigList clear the destination list before assigning

values to it. This cuts down on memleaks which could exist when the function was
 not used carefully.
replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
Darkvater 18 years ago
parent 39eff474d3
commit 739e93fd23

@ -115,6 +115,8 @@ GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src)
{
GRFConfig *c;
/* Clear destination as it will be overwritten */
ClearGRFConfigList(dst);
for (; src != NULL; src = src->next) {
c = calloc(1, sizeof(*c));
*c = *src;
@ -135,8 +137,6 @@ void ResetGRFConfig(bool defaults)
{
GRFConfig **c = &_grfconfig;
ClearGRFConfigList(c);
if (defaults) c = CopyGRFConfigList(c, _grfconfig_newgame);
CopyGRFConfigList(c, _grfconfig_static);
}

Loading…
Cancel
Save