From 1812bcfc8c20dfea2df38da7f7b042c2d62f551b Mon Sep 17 00:00:00 2001 From: Darkvater Date: Wed, 20 Dec 2006 20:43:52 +0000 Subject: (svn r7517) -Codechange: Set pointers to NULL when freeing the newgrf config variables and add the proper const to CopyGRFConfigList --- newgrf_config.c | 17 +++++++++-------- newgrf_config.h | 3 ++- settings.c | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/newgrf_config.c b/newgrf_config.c index 924c3c628..b0f06d110 100644 --- a/newgrf_config.c +++ b/newgrf_config.c @@ -82,15 +82,16 @@ bool FillGRFDetails(GRFConfig *config, bool is_static) } -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 @@ void ClearGRFConfigList(GRFConfig *config) 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 --git a/newgrf_config.h b/newgrf_config.h index 42ab2feef..c6f49bb60 100644 --- a/newgrf_config.h +++ b/newgrf_config.h @@ -43,7 +43,8 @@ extern GRFConfig *_grfconfig_static; 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 --git a/settings.c b/settings.c index 498f5d2f1..af40febfa 100644 --- a/settings.c +++ b/settings.c @@ -1534,7 +1534,7 @@ static GRFConfig *GRFLoadConfig(IniFile *ini, const char *grpname, bool is_stati } ShowInfoF("ini: ignoring invalid NewGRF '%s': %s", item->name, msg); - ClearGRFConfig(c); + ClearGRFConfig(&c); continue; } -- cgit v1.2.3-70-g09d2