diff options
author | Darkvater <darkvater@openttd.org> | 2006-12-20 21:17:33 +0000 |
---|---|---|
committer | Darkvater <darkvater@openttd.org> | 2006-12-20 21:17:33 +0000 |
commit | 28042b65ac4574a3bcf3fa2ff206e62f498492b2 (patch) | |
tree | 5b8c27872faf8943144f2948020a199b2cbb85c1 /newgrf_config.c | |
parent | 1812bcfc8c20dfea2df38da7f7b042c2d62f551b (diff) | |
download | openttd-28042b65ac4574a3bcf3fa2ff206e62f498492b2.tar.xz |
(svn r7518) -Codechange: more NULL pointer resets after free.
Diffstat (limited to 'newgrf_config.c')
-rw-r--r-- | newgrf_config.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/newgrf_config.c b/newgrf_config.c index b0f06d110..6caec3e04 100644 --- a/newgrf_config.c +++ b/newgrf_config.c @@ -96,17 +96,21 @@ void ClearGRFConfig(GRFConfig **config) /* Clear a GRF Config list */ -void ClearGRFConfigList(GRFConfig *config) +void ClearGRFConfigList(GRFConfig **config) { GRFConfig *c, *next; - for (c = config; c != NULL; c = next) { + for (c = *config; c != NULL; c = next) { next = c->next; ClearGRFConfig(&c); } + *config = NULL; } -/* Copy a GRF Config list */ +/** Copy a GRF Config list + * @param dst pointer to destination list + * @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; @@ -131,8 +135,7 @@ void ResetGRFConfig(bool defaults) { GRFConfig **c = &_grfconfig; - ClearGRFConfigList(_grfconfig); - _grfconfig = NULL; + ClearGRFConfigList(c); if (defaults) c = CopyGRFConfigList(c, _grfconfig_newgame); CopyGRFConfigList(c, _grfconfig_static); @@ -244,8 +247,7 @@ void ScanNewGRFFiles(void) { uint num; - ClearGRFConfigList(_all_grfs); - _all_grfs = NULL; + ClearGRFConfigList(&_all_grfs); DEBUG(grf, 1) ("[GRF] Scanning for NewGRFs"); num = ScanPath(_paths.data_dir); @@ -388,7 +390,7 @@ static void Load_NGRF(void) /* Append static NewGRF configuration */ CopyGRFConfigList(last, _grfconfig_static); - ClearGRFConfigList(_grfconfig); + ClearGRFConfigList(&_grfconfig); _grfconfig = first; } |