# HG changeset patch # User Darkvater # Date 1166647432 0 # Node ID 0d7cc9cefd2b1d315a2a6e37787ed671b3a83c18 # Parent 00c5ff01191ab501e4b9364e503974fc54d43a36 (svn r7517) -Codechange: Set pointers to NULL when freeing the newgrf config variables and add the proper const to CopyGRFConfigList diff -r 00c5ff01191a -r 0d7cc9cefd2b newgrf_config.c --- a/newgrf_config.c Wed Dec 20 19:16:44 2006 +0000 +++ b/newgrf_config.c Wed Dec 20 20:43:52 2006 +0000 @@ -82,15 +82,16 @@ } -void ClearGRFConfig(GRFConfig *config) +void ClearGRFConfig(GRFConfig **config) { /* GCF_COPY as in NOT strdupped/alloced the filename, name and info */ - if (!HASBIT(config->flags, GCF_COPY)) { - free(config->filename); - free(config->name); - free(config->info); + if (!HASBIT((*config)->flags, GCF_COPY)) { + free((*config)->filename); + free((*config)->name); + free((*config)->info); } - free(config); + free(*config); + *config = NULL; } @@ -100,13 +101,13 @@ GRFConfig *c, *next; for (c = config; c != NULL; c = next) { next = c->next; - ClearGRFConfig(c); + ClearGRFConfig(&c); } } /* Copy a GRF Config list */ -static GRFConfig **CopyGRFConfigList(GRFConfig **dst, GRFConfig *src) +GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src) { GRFConfig *c; diff -r 00c5ff01191a -r 0d7cc9cefd2b newgrf_config.h --- a/newgrf_config.h Wed Dec 20 19:16:44 2006 +0000 +++ b/newgrf_config.h Wed Dec 20 20:43:52 2006 +0000 @@ -43,7 +43,8 @@ void ScanNewGRFFiles(void); const GRFConfig *FindGRFConfig(uint32 grfid, uint8 *md5sum); GRFConfig *GetGRFConfig(uint32 grfid); -void ClearGRFConfig(GRFConfig *config); +GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src); +void ClearGRFConfig(GRFConfig **config); void ClearGRFConfigList(GRFConfig *config); void ResetGRFConfig(bool defaults); bool IsGoodGRFConfigList(void); diff -r 00c5ff01191a -r 0d7cc9cefd2b settings.c --- a/settings.c Wed Dec 20 19:16:44 2006 +0000 +++ b/settings.c Wed Dec 20 20:43:52 2006 +0000 @@ -1534,7 +1534,7 @@ } ShowInfoF("ini: ignoring invalid NewGRF '%s': %s", item->name, msg); - ClearGRFConfig(c); + ClearGRFConfig(&c); continue; }