Changeset - r5351:78ec7c00eea3
[Not reviewed]
master
0 1 0
Darkvater - 17 years ago 2006-12-21 10:09:43
darkvater@openttd.org
(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.
1 file changed with 2 insertions and 2 deletions:
0 comments (0 inline, 0 general)
newgrf_config.c
Show inline comments
 
@@ -112,12 +112,14 @@ void ClearGRFConfigList(GRFConfig **conf
 
 * @param srt pointer to source list values
 
 * @return pointer to the last value added to the destination list */
 
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;
 
		c->filename = strdup(src->filename);
 
		if (src->name != NULL) c->name = strdup(src->name);
 
		if (src->info != NULL) c->info = strdup(src->info);
 
@@ -132,14 +134,12 @@ GRFConfig **CopyGRFConfigList(GRFConfig 
 

	
 
/* Reset the current GRF Config to either blank or newgame settings */
 
void ResetGRFConfig(bool defaults)
 
{
 
	GRFConfig **c = &_grfconfig;
 

	
 
	ClearGRFConfigList(c);
 

	
 
	if (defaults) c = CopyGRFConfigList(c, _grfconfig_newgame);
 
	CopyGRFConfigList(c, _grfconfig_static);
 
}
 

	
 

	
 
/* Check if all GRFs in the GRF Config can be loaded */
0 comments (0 inline, 0 general)