Mercurial > hg > openttd
changeset 5346:32f108f1c4c5 draft
(svn r7517) -Codechange: Set pointers to NULL when freeing the newgrf config variables and add the proper const to CopyGRFConfigList
author | Darkvater <Darkvater@openttd.org> |
---|---|
date | Wed, 20 Dec 2006 20:43:52 +0000 |
parents | dd432d4440ae |
children | 95a331742793 |
files | newgrf_config.c newgrf_config.h settings.c |
diffstat | 3 files changed, 12 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/newgrf_config.c +++ b/newgrf_config.c @@ -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;
--- a/newgrf_config.h +++ b/newgrf_config.h @@ -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);