mirror of https://github.com/OpenTTD/OpenTTD
(svn r7518) -Codechange: more NULL pointer resets after free.
parent
1812bcfc8c
commit
28042b65ac
|
@ -59,9 +59,10 @@ void NetworkGameListRemoveItem(NetworkGameList *remove)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove GRFConfig information */
|
/* Remove GRFConfig information */
|
||||||
ClearGRFConfigList(remove->info.grfconfig);
|
ClearGRFConfigList(&remove->info.grfconfig);
|
||||||
|
|
||||||
free(remove);
|
free(remove);
|
||||||
|
remove = NULL;
|
||||||
|
|
||||||
DEBUG(net, 4) ("[NET][GameList] Removed server from list");
|
DEBUG(net, 4) ("[NET][GameList] Removed server from list");
|
||||||
UpdateNetworkGameWindow(false);
|
UpdateNetworkGameWindow(false);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -96,17 +96,21 @@ void ClearGRFConfig(GRFConfig **config)
|
||||||
|
|
||||||
|
|
||||||
/* Clear a GRF Config list */
|
/* Clear a GRF Config list */
|
||||||
void ClearGRFConfigList(GRFConfig *config)
|
void ClearGRFConfigList(GRFConfig **config)
|
||||||
{
|
{
|
||||||
GRFConfig *c, *next;
|
GRFConfig *c, *next;
|
||||||
for (c = config; c != NULL; c = next) {
|
for (c = *config; c != NULL; c = next) {
|
||||||
next = c->next;
|
next = c->next;
|
||||||
ClearGRFConfig(&c);
|
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 **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src)
|
||||||
{
|
{
|
||||||
GRFConfig *c;
|
GRFConfig *c;
|
||||||
|
@ -131,8 +135,7 @@ void ResetGRFConfig(bool defaults)
|
||||||
{
|
{
|
||||||
GRFConfig **c = &_grfconfig;
|
GRFConfig **c = &_grfconfig;
|
||||||
|
|
||||||
ClearGRFConfigList(_grfconfig);
|
ClearGRFConfigList(c);
|
||||||
_grfconfig = NULL;
|
|
||||||
|
|
||||||
if (defaults) c = CopyGRFConfigList(c, _grfconfig_newgame);
|
if (defaults) c = CopyGRFConfigList(c, _grfconfig_newgame);
|
||||||
CopyGRFConfigList(c, _grfconfig_static);
|
CopyGRFConfigList(c, _grfconfig_static);
|
||||||
|
@ -244,8 +247,7 @@ void ScanNewGRFFiles(void)
|
||||||
{
|
{
|
||||||
uint num;
|
uint num;
|
||||||
|
|
||||||
ClearGRFConfigList(_all_grfs);
|
ClearGRFConfigList(&_all_grfs);
|
||||||
_all_grfs = NULL;
|
|
||||||
|
|
||||||
DEBUG(grf, 1) ("[GRF] Scanning for NewGRFs");
|
DEBUG(grf, 1) ("[GRF] Scanning for NewGRFs");
|
||||||
num = ScanPath(_paths.data_dir);
|
num = ScanPath(_paths.data_dir);
|
||||||
|
@ -388,7 +390,7 @@ static void Load_NGRF(void)
|
||||||
/* Append static NewGRF configuration */
|
/* Append static NewGRF configuration */
|
||||||
CopyGRFConfigList(last, _grfconfig_static);
|
CopyGRFConfigList(last, _grfconfig_static);
|
||||||
|
|
||||||
ClearGRFConfigList(_grfconfig);
|
ClearGRFConfigList(&_grfconfig);
|
||||||
_grfconfig = first;
|
_grfconfig = first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ const GRFConfig *FindGRFConfig(uint32 grfid, uint8 *md5sum);
|
||||||
GRFConfig *GetGRFConfig(uint32 grfid);
|
GRFConfig *GetGRFConfig(uint32 grfid);
|
||||||
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src);
|
GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src);
|
||||||
void ClearGRFConfig(GRFConfig **config);
|
void ClearGRFConfig(GRFConfig **config);
|
||||||
void ClearGRFConfigList(GRFConfig *config);
|
void ClearGRFConfigList(GRFConfig **config);
|
||||||
void ResetGRFConfig(bool defaults);
|
void ResetGRFConfig(bool defaults);
|
||||||
bool IsGoodGRFConfigList(void);
|
bool IsGoodGRFConfigList(void);
|
||||||
bool FillGRFDetails(GRFConfig *config, bool is_static);
|
bool FillGRFDetails(GRFConfig *config, bool is_static);
|
||||||
|
|
Loading…
Reference in New Issue