Changeset - r21012:644a32ba9af2
[Not reviewed]
master
0 2 0
rubidium - 11 years ago 2013-11-24 15:21:38
rubidium@openttd.org
(svn r26089) -Fix: a number of minor memory leaks
2 files changed with 33 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/fileio.cpp
Show inline comments
 
@@ -1083,8 +1083,11 @@ void DetermineBasePaths(const char *exe)
 
{
 
	char tmp[MAX_PATH];
 
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
 
	snprintf(tmp, MAX_PATH, "%s" PATHSEP "%s", xdgDataHome(NULL),
 
	const char *xdg_data_home = xdgDataHome(NULL);
 
	snprintf(tmp, MAX_PATH, "%s" PATHSEP "%s", xdg_data_home,
 
			PERSONAL_DIR[0] == '.' ? &PERSONAL_DIR[1] : PERSONAL_DIR);
 
	free(xdg_data_home);
 

	
 
	AppendPathSeparator(tmp, MAX_PATH);
 
	_searchpaths[SP_PERSONAL_DIR_XDG] = strdup(tmp);
 
#endif
 
@@ -1174,8 +1177,12 @@ void DeterminePaths(const char *exe)
 

	
 
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
 
	char config_home[MAX_PATH];
 
	snprintf(config_home, MAX_PATH, "%s" PATHSEP "%s", xdgConfigHome(NULL),
 

	
 
	const char *xdg_config_home = xdgConfigHome(NULL);
 
	snprintf(config_home, MAX_PATH, "%s" PATHSEP "%s", xdg_config_home,
 
			PERSONAL_DIR[0] == '.' ? &PERSONAL_DIR[1] : PERSONAL_DIR);
 
	free(xdg_config_home);
 

	
 
	AppendPathSeparator(config_home, MAX_PATH);
 
#endif
 

	
src/openttd.cpp
Show inline comments
 
@@ -557,6 +557,7 @@ int openttd_main(int argc, char *argv[])
 
	_config_file = NULL;
 

	
 
	GetOptData mgo(argc - 1, argv + 1, _options);
 
	int ret = 0;
 

	
 
	int i;
 
	while ((i = mgo.GetOpt()) != -1) {
 
@@ -637,8 +638,14 @@ int openttd_main(int argc, char *argv[])
 
			}
 
			break;
 
		case 'q': {
 
			delete scanner;
 

	
 
			DeterminePaths(argv[0]);
 
			if (StrEmpty(mgo.opt)) return 1;
 
			if (StrEmpty(mgo.opt)) {
 
				ret = 1;
 
				goto exit_noshutdown;
 
			}
 

	
 
			char title[80];
 
			title[0] = '\0';
 
			FiosGetSavegameListCallback(SLD_LOAD_GAME, mgo.opt, strrchr(mgo.opt, '.'), title, lastof(title));
 
@@ -653,12 +660,12 @@ int openttd_main(int argc, char *argv[])
 
					GetString(buf, _load_check_data.error, lastof(buf));
 
					fprintf(stderr, "%s\n", buf);
 
				}
 
				return 1;
 
				goto exit_noshutdown;
 
			}
 

	
 
			WriteSavegameInfo(title);
 

	
 
			return 0;
 
			goto exit_noshutdown;
 
		}
 
		case 'G': scanner->generation_seed = atoi(mgo.opt); break;
 
		case 'c': _config_file = strdup(mgo.opt); break;
 
@@ -683,7 +690,8 @@ int openttd_main(int argc, char *argv[])
 
		BaseMusic::FindSets();
 
		ShowHelp();
 
		delete scanner;
 
		return 0;
 

	
 
		goto exit_noshutdown;
 
	}
 

	
 
#if defined(WINCE) && defined(_DEBUG)
 
@@ -870,15 +878,26 @@ exit:
 
	/* Reset windowing system, stop drivers, free used memory, ... */
 
	ShutdownGame();
 

	
 
exit_noshutdown:
 
	free(BaseGraphics::ini_set);
 
	free(BaseSounds::ini_set);
 
	free(BaseMusic::ini_set);
 

	
 
	free(graphics_set);
 
	free(sounds_set);
 
	free(music_set);
 

	
 
	free(_ini_musicdriver);
 
	free(_ini_sounddriver);
 
	free(_ini_videodriver);
 
	free(_ini_blitter);
 

	
 
	return 0;
 
	free(musicdriver);
 
	free(sounddriver);
 
	free(videodriver);
 
	free(blitter);
 

	
 
	return ret;
 
}
 

	
 
void HandleExitGameRequest()
0 comments (0 inline, 0 general)