Changeset - r21410:ae5961f02724
[Not reviewed]
master
! ! !
rubidium - 11 years ago 2014-04-25 15:40:32
rubidium@openttd.org
(svn r26509) -Codechange: replace strdup with stredup (the latter ensures the return is not NULL)
70 files changed with 207 insertions and 183 deletions:
0 comments (0 inline, 0 general)
src/ai/ai_config.cpp
Show inline comments
 
@@ -11,6 +11,7 @@
 

	
 
#include "../stdafx.h"
 
#include "../settings_type.h"
 
#include "../string_func.h"
 
#include "ai.hpp"
 
#include "ai_config.hpp"
 
#include "ai_info.hpp"
 
@@ -109,7 +110,7 @@ void AIConfig::SetSetting(const char *na
 
		if (it != this->settings.end()) {
 
			(*it).second = value;
 
		} else {
 
			this->settings[strdup(name)] = value;
 
			this->settings[stredup(name)] = value;
 
		}
 

	
 
		return;
src/ai/ai_info.cpp
Show inline comments
 
@@ -15,6 +15,7 @@
 
#include "ai_info.hpp"
 
#include "ai_scanner.hpp"
 
#include "../debug.h"
 
#include "../string_func.h"
 
#include "../rev.h"
 

	
 
#include "../safeguards.h"
 
@@ -71,8 +72,8 @@ template <> const char *GetClassName<AII
 
	if (res != 0) return res;
 

	
 
	ScriptConfigItem config = _start_date_config;
 
	config.name = strdup(config.name);
 
	config.description = strdup(config.description);
 
	config.name = stredup(config.name);
 
	config.description = stredup(config.description);
 
	info->config_list.push_front(config);
 

	
 
	if (info->engine->MethodExists(*info->SQ_instance, "MinVersionToLoad")) {
 
@@ -94,7 +95,7 @@ template <> const char *GetClassName<AII
 
			return SQ_ERROR;
 
		}
 
	} else {
 
		info->api_version = strdup("0.7");
 
		info->api_version = stredup("0.7");
 
	}
 

	
 
	/* Remove the link to the real instance, else it might get deleted by RegisterAI() */
 
@@ -117,7 +118,7 @@ template <> const char *GetClassName<AII
 

	
 
	char buf[8];
 
	seprintf(buf, lastof(buf), "%d.%d", GB(_openttd_newgrf_version, 28, 4), GB(_openttd_newgrf_version, 24, 4));
 
	info->api_version = strdup(buf);
 
	info->api_version = stredup(buf);
 

	
 
	/* Remove the link to the real instance, else it might get deleted by RegisterAI() */
 
	sq_setinstanceup(vm, 2, NULL);
src/ai/ai_scanner.cpp
Show inline comments
 
@@ -33,7 +33,7 @@ void AIScannerInfo::Initialize()
 

	
 
	/* Create the dummy AI */
 
	free(this->main_script);
 
	this->main_script = strdup("%_dummy");
 
	this->main_script = stredup("%_dummy");
 
	extern void Script_CreateDummyInfo(HSQUIRRELVM vm, const char *type, const char *dir);
 
	Script_CreateDummyInfo(this->engine->GetVM(), "AI", "ai");
 
}
src/base_consist.cpp
Show inline comments
 
@@ -12,6 +12,7 @@
 
#include "stdafx.h"
 
#include "base_consist.h"
 
#include "vehicle_base.h"
 
#include "string_func.h"
 

	
 
#include "safeguards.h"
 

	
 
@@ -29,7 +30,7 @@ void BaseConsist::CopyConsistPropertiesF
 
	if (this == src) return;
 

	
 
	free(this->name);
 
	this->name = src->name != NULL ? strdup(src->name) : NULL;
 
	this->name = src->name != NULL ? stredup(src->name) : NULL;
 

	
 
	this->current_order_time = src->current_order_time;
 
	this->lateness_counter = src->lateness_counter;
src/base_media_func.h
Show inline comments
 
@@ -51,16 +51,16 @@ bool BaseSet<T, Tnum_files, Tsearch_in_t
 
	IniItem *item;
 

	
 
	fetch_metadata("name");
 
	this->name = strdup(item->value);
 
	this->name = stredup(item->value);
 

	
 
	fetch_metadata("description");
 
	this->description[strdup("")] = strdup(item->value);
 
	this->description[stredup("")] = stredup(item->value);
 

	
 
	/* Add the translations of the descriptions too. */
 
	for (const IniItem *item = metadata->item; item != NULL; item = item->next) {
 
		if (strncmp("description.", item->name, 12) != 0) continue;
 

	
 
		this->description[strdup(item->name + 12)] = strdup(item->value);
 
		this->description[stredup(item->name + 12)] = stredup(item->value);
 
	}
 

	
 
	fetch_metadata("shortname");
 
@@ -129,9 +129,9 @@ bool BaseSet<T, Tnum_files, Tsearch_in_t
 
		if (item == NULL) item = origin->GetItem("default", false);
 
		if (item == NULL) {
 
			DEBUG(grf, 1, "No origin warning message specified for: %s", filename);
 
			file->missing_warning = strdup("");
 
			file->missing_warning = stredup("");
 
		} else {
 
			file->missing_warning = strdup(item->value);
 
			file->missing_warning = stredup(item->value);
 
		}
 

	
 
		switch (T::CheckMD5(file, BASESET_DIR)) {
 
@@ -164,7 +164,7 @@ bool BaseMedia<Tbase_set>::AddFile(const
 
	IniFile *ini = new IniFile();
 
	ini->LoadFromDisk(filename, BASESET_DIR);
 

	
 
	char *path = strdup(filename + basepath_length);
 
	char *path = stredup(filename + basepath_length);
 
	char *psep = strrchr(path, PATHSEPCHAR);
 
	if (psep != NULL) {
 
		psep[1] = '\0';
src/blitter/factory.hpp
Show inline comments
 
@@ -63,7 +63,7 @@ protected:
 
	 * @pre There is no blitter registered with this name.
 
	 */
 
	BlitterFactory(const char *name, const char *description, bool usable = true) :
 
			name(strdup(name)), description(strdup(description))
 
			name(stredup(name)), description(stredup(description))
 
	{
 
		if (usable) {
 
			/*
src/company_cmd.cpp
Show inline comments
 
@@ -1114,7 +1114,7 @@ CommandCost CmdRenameCompany(TileIndex t
 
	if (flags & DC_EXEC) {
 
		Company *c = Company::Get(_current_company);
 
		free(c->name);
 
		c->name = reset ? NULL : strdup(text);
 
		c->name = reset ? NULL : stredup(text);
 
		MarkWholeScreenDirty();
 
		CompanyAdminUpdate(c);
 
	}
 
@@ -1163,7 +1163,7 @@ CommandCost CmdRenamePresident(TileIndex
 
		if (reset) {
 
			c->president_name = NULL;
 
		} else {
 
			c->president_name = strdup(text);
 
			c->president_name = stredup(text);
 

	
 
			if (c->name_1 == STR_SV_UNNAMED && c->name == NULL) {
 
				char buf[80];
src/console.cpp
Show inline comments
 
@@ -105,7 +105,7 @@ void IConsolePrint(TextColour colour_cod
 

	
 
	/* Create a copy of the string, strip if of colours and invalid
 
	 * characters and (when applicable) assign it to the console buffer */
 
	str = strdup(string);
 
	str = stredup(string);
 
	str_strip_colours(str);
 
	str_validate(str, str + strlen(str));
 

	
 
@@ -256,7 +256,7 @@ char *RemoveUnderscores(char *name)
 
void IConsoleCmdRegister(const char *name, IConsoleCmdProc *proc, IConsoleHook *hook)
 
{
 
	IConsoleCmd *item_new = MallocT<IConsoleCmd>(1);
 
	item_new->name = RemoveUnderscores(strdup(name));
 
	item_new->name = RemoveUnderscores(stredup(name));
 
	item_new->next = NULL;
 
	item_new->proc = proc;
 
	item_new->hook = hook;
 
@@ -291,8 +291,8 @@ void IConsoleAliasRegister(const char *n
 
		return;
 
	}
 

	
 
	char *new_alias = RemoveUnderscores(strdup(name));
 
	char *cmd_aliased = strdup(cmd);
 
	char *new_alias = RemoveUnderscores(stredup(name));
 
	char *cmd_aliased = stredup(cmd);
 
	IConsoleAlias *item_new = MallocT<IConsoleAlias>(1);
 

	
 
	item_new->next = NULL;
src/console_cmds.cpp
Show inline comments
 
@@ -1344,7 +1344,7 @@ DEF_CONSOLE_CMD(ConAlias)
 
		IConsoleAliasRegister(argv[1], argv[2]);
 
	} else {
 
		free(alias->cmdline);
 
		alias->cmdline = strdup(argv[2]);
 
		alias->cmdline = stredup(argv[2]);
 
	}
 
	return true;
 
}
src/console_gui.cpp
Show inline comments
 
@@ -465,7 +465,7 @@ static const char *IConsoleHistoryAdd(co
 
	if (_iconsole_history[0] == NULL || strcmp(_iconsole_history[0], cmd) != 0) {
 
		free(_iconsole_history[ICON_HISTORY_SIZE - 1]);
 
		memmove(&_iconsole_history[1], &_iconsole_history[0], sizeof(_iconsole_history[0]) * (ICON_HISTORY_SIZE - 1));
 
		_iconsole_history[0] = strdup(cmd);
 
		_iconsole_history[0] = stredup(cmd);
 
	}
 

	
 
	/* Reset the history position */
src/depot_cmd.cpp
Show inline comments
 
@@ -70,7 +70,7 @@ CommandCost CmdRenameDepot(TileIndex til
 
			d->name = NULL;
 
			MakeDefaultName(d);
 
		} else {
 
			d->name = strdup(text);
 
			d->name = stredup(text);
 
		}
 

	
 
		/* Update the orders and depot */
src/driver.cpp
Show inline comments
 
@@ -208,7 +208,7 @@ DriverFactoryBase::DriverFactoryBase(Dri
 
	strecpy(buf, GetDriverTypeName(type), lastof(buf));
 
	strecpy(buf + 5, name, lastof(buf));
 

	
 
	const char *longname = strdup(buf);
 
	const char *longname = stredup(buf);
 

	
 
	std::pair<Drivers::iterator, bool> P = GetDrivers().insert(Drivers::value_type(longname, this));
 
	assert(P.second);
src/engine.cpp
Show inline comments
 
@@ -1027,7 +1027,7 @@ CommandCost CmdRenameEngine(TileIndex ti
 
		if (reset) {
 
			e->name = NULL;
 
		} else {
 
			e->name = strdup(text);
 
			e->name = stredup(text);
 
		}
 

	
 
		MarkWholeScreenDirty();
src/error_gui.cpp
Show inline comments
 
@@ -77,7 +77,7 @@ ErrorMessageData::ErrorMessageData(const
 
	*this = data;
 
	for (size_t i = 0; i < lengthof(this->strings); i++) {
 
		if (this->strings[i] != NULL) {
 
			this->strings[i] = strdup(this->strings[i]);
 
			this->strings[i] = stredup(this->strings[i]);
 
			this->decode_params[i] = (size_t)this->strings[i];
 
		}
 
	}
 
@@ -158,7 +158,7 @@ void ErrorMessageData::SetDParam(uint n,
 
void ErrorMessageData::SetDParamStr(uint n, const char *str)
 
{
 
	free(this->strings[n]);
 
	this->strings[n] = strdup(str);
 
	this->strings[n] = stredup(str);
 
}
 

	
 
/** Define a queue with errors. */
src/fileio.cpp
Show inline comments
 
@@ -265,7 +265,7 @@ void FioOpenFile(int slot, const char *f
 

	
 
	/* Store the filename without path and extension */
 
	const char *t = strrchr(filename, PATHSEPCHAR);
 
	_fio.shortnames[slot] = strdup(t == NULL ? filename : t);
 
	_fio.shortnames[slot] = stredup(t == NULL ? filename : t);
 
	char *t2 = strrchr(_fio.shortnames[slot], '.');
 
	if (t2 != NULL) *t2 = '\0';
 
	strtolower(_fio.shortnames[slot]);
 
@@ -755,7 +755,7 @@ bool TarScanner::AddFile(const char *fil
 
	 * been given read access. */
 
	if (f == NULL) return false;
 

	
 
	const char *dupped_filename = strdup(filename);
 
	const char *dupped_filename = stredup(filename);
 
	_tar_list[this->subdir][filename].filename = dupped_filename;
 
	_tar_list[this->subdir][filename].dirname = NULL;
 

	
 
@@ -892,7 +892,7 @@ bool TarScanner::AddFile(const char *fil
 

	
 
				/* Store the first directory name we detect */
 
				DEBUG(misc, 6, "Found dir in tar: %s", name);
 
				if (_tar_list[this->subdir][filename].dirname == NULL) _tar_list[this->subdir][filename].dirname = strdup(name);
 
				if (_tar_list[this->subdir][filename].dirname == NULL) _tar_list[this->subdir][filename].dirname = stredup(name);
 
				break;
 

	
 
			default:
 
@@ -1091,7 +1091,7 @@ void DetermineBasePaths(const char *exe)
 
	free(xdg_data_home);
 

	
 
	AppendPathSeparator(tmp, lastof(tmp));
 
	_searchpaths[SP_PERSONAL_DIR_XDG] = strdup(tmp);
 
	_searchpaths[SP_PERSONAL_DIR_XDG] = stredup(tmp);
 
#endif
 
#if defined(__MORPHOS__) || defined(__AMIGA__) || defined(DOS) || defined(OS2) || !defined(WITH_PERSONAL_DIR)
 
	_searchpaths[SP_PERSONAL_DIR] = NULL;
 
@@ -1099,7 +1099,7 @@ void DetermineBasePaths(const char *exe)
 
#ifdef __HAIKU__
 
	BPath path;
 
	find_directory(B_USER_SETTINGS_DIRECTORY, &path);
 
	const char *homedir = strdup(path.Path());
 
	const char *homedir = stredup(path.Path());
 
#else
 
	/* getenv is highly unsafe; duplicate it as soon as possible,
 
	 * or at least before something else touches the environment
 
@@ -1112,7 +1112,7 @@ void DetermineBasePaths(const char *exe)
 

	
 
	if (homedir == NULL) {
 
		const struct passwd *pw = getpwuid(getuid());
 
		homedir = (pw == NULL) ? NULL : strdup(pw->pw_dir);
 
		homedir = (pw == NULL) ? NULL : stredup(pw->pw_dir);
 
	}
 
#endif
 

	
 
@@ -1121,7 +1121,7 @@ void DetermineBasePaths(const char *exe)
 
		seprintf(tmp, lastof(tmp), "%s" PATHSEP "%s", homedir, PERSONAL_DIR);
 
		AppendPathSeparator(tmp, lastof(tmp));
 

	
 
		_searchpaths[SP_PERSONAL_DIR] = strdup(tmp);
 
		_searchpaths[SP_PERSONAL_DIR] = stredup(tmp);
 
		free(homedir);
 
	} else {
 
		_searchpaths[SP_PERSONAL_DIR] = NULL;
 
@@ -1131,7 +1131,7 @@ void DetermineBasePaths(const char *exe)
 
#if defined(WITH_SHARED_DIR)
 
	seprintf(tmp, lastof(tmp), "%s", SHARED_DIR);
 
	AppendPathSeparator(tmp, lastof(tmp));
 
	_searchpaths[SP_SHARED_DIR] = strdup(tmp);
 
	_searchpaths[SP_SHARED_DIR] = stredup(tmp);
 
#else
 
	_searchpaths[SP_SHARED_DIR] = NULL;
 
#endif
 
@@ -1141,7 +1141,7 @@ void DetermineBasePaths(const char *exe)
 
#else
 
	if (getcwd(tmp, MAX_PATH) == NULL) *tmp = '\0';
 
	AppendPathSeparator(tmp, lastof(tmp));
 
	_searchpaths[SP_WORKING_DIR] = strdup(tmp);
 
	_searchpaths[SP_WORKING_DIR] = stredup(tmp);
 
#endif
 

	
 
	_do_scan_working_directory = DoScanWorkingDirectory();
 
@@ -1150,7 +1150,7 @@ void DetermineBasePaths(const char *exe)
 
	if (ChangeWorkingDirectoryToExecutable(exe)) {
 
		if (getcwd(tmp, MAX_PATH) == NULL) *tmp = '\0';
 
		AppendPathSeparator(tmp, lastof(tmp));
 
		_searchpaths[SP_BINARY_DIR] = strdup(tmp);
 
		_searchpaths[SP_BINARY_DIR] = stredup(tmp);
 
	} else {
 
		_searchpaths[SP_BINARY_DIR] = NULL;
 
	}
 
@@ -1167,7 +1167,7 @@ void DetermineBasePaths(const char *exe)
 
#else
 
	seprintf(tmp, lastof(tmp), "%s", GLOBAL_DATA_DIR);
 
	AppendPathSeparator(tmp, lastof(tmp));
 
	_searchpaths[SP_INSTALLATION_DIR] = strdup(tmp);
 
	_searchpaths[SP_INSTALLATION_DIR] = stredup(tmp);
 
#endif
 
#ifdef WITH_COCOA
 
extern void cocoaSetApplicationBundleDir();
 
@@ -1209,7 +1209,7 @@ void DeterminePaths(const char *exe)
 

	
 
	char *config_dir;
 
	if (_config_file != NULL) {
 
		config_dir = strdup(_config_file);
 
		config_dir = stredup(_config_file);
 
		char *end = strrchr(config_dir, PATHSEPCHAR);
 
		if (end == NULL) {
 
			config_dir[0] = '\0';
 
@@ -1221,7 +1221,7 @@ void DeterminePaths(const char *exe)
 
		if (FioFindFullPath(personal_dir, lastof(personal_dir), BASE_DIR, "openttd.cfg") != NULL) {
 
			char *end = strrchr(personal_dir, PATHSEPCHAR);
 
			if (end != NULL) end[1] = '\0';
 
			config_dir = strdup(personal_dir);
 
			config_dir = stredup(personal_dir);
 
			_config_file = str_fmt("%sopenttd.cfg", config_dir);
 
		} else {
 
#if defined(WITH_XDG_BASEDIR) && defined(WITH_PERSONAL_DIR)
 
@@ -1235,7 +1235,7 @@ void DeterminePaths(const char *exe)
 
			config_dir = NULL;
 
			for (uint i = 0; i < lengthof(new_openttd_cfg_order); i++) {
 
				if (IsValidSearchPath(new_openttd_cfg_order[i])) {
 
					config_dir = strdup(_searchpaths[new_openttd_cfg_order[i]]);
 
					config_dir = stredup(_searchpaths[new_openttd_cfg_order[i]]);
 
					break;
 
				}
 
			}
src/fontdetection.cpp
Show inline comments
 
@@ -566,7 +566,7 @@ FT_Error GetFontByFaceName(const char *f
 
		char *font_family;
 

	
 
		/* Split & strip the font's style */
 
		font_family = strdup(font_name);
 
		font_family = stredup(font_name);
 
		font_style = strchr(font_family, ',');
 
		if (font_style != NULL) {
 
			font_style[0] = '\0';
src/game/game_text.cpp
Show inline comments
 
@@ -212,7 +212,7 @@ struct StringNameWriter : HeaderWriter {
 

	
 
	void WriteStringID(const char *name, int stringid)
 
	{
 
		if (stringid == (int)this->strings->Length()) *this->strings->Append() = strdup(name);
 
		if (stringid == (int)this->strings->Length()) *this->strings->Append() = stredup(name);
 
	}
 

	
 
	void Finalise(const StringData &data)
 
@@ -231,7 +231,7 @@ private:
 

	
 
public:
 
	/** Initialise */
 
	LanguageScanner(GameStrings *gs, const char *exclude) : gs(gs), exclude(strdup(exclude)) {}
 
	LanguageScanner(GameStrings *gs, const char *exclude) : gs(gs), exclude(stredup(exclude)) {}
 
	~LanguageScanner() { free(exclude); }
 

	
 
	/**
src/gamelog.cpp
Show inline comments
 
@@ -462,7 +462,7 @@ void GamelogSetting(const char *name, in
 
	LoggedChange *lc = GamelogChange(GLCT_SETTING);
 
	if (lc == NULL) return;
 

	
 
	lc->setting.name = strdup(name);
 
	lc->setting.name = stredup(name);
 
	lc->setting.oldval = oldval;
 
	lc->setting.newval = newval;
 
}
src/goal.cpp
Show inline comments
 
@@ -90,7 +90,7 @@ CommandCost CmdCreateGoal(TileIndex tile
 
		g->type = type;
 
		g->dst = p2;
 
		g->company = company;
 
		g->text = strdup(text);
 
		g->text = stredup(text);
 
		g->progress = NULL;
 
		g->completed = false;
 

	
 
@@ -155,7 +155,7 @@ CommandCost CmdSetGoalText(TileIndex til
 
	if (flags & DC_EXEC) {
 
		Goal *g = Goal::Get(p1);
 
		free(g->text);
 
		g->text = strdup(text);
 
		g->text = stredup(text);
 

	
 
		if (g->company == INVALID_COMPANY) {
 
			InvalidateWindowClassesData(WC_GOALS_LIST);
 
@@ -187,7 +187,7 @@ CommandCost CmdSetGoalProgress(TileIndex
 
		if (StrEmpty(text)) {
 
			g->progress = NULL;
 
		} else {
 
			g->progress = strdup(text);
 
			g->progress = stredup(text);
 
		}
 

	
 
		if (g->company == INVALID_COMPANY) {
src/goal_gui.cpp
Show inline comments
 
@@ -23,6 +23,7 @@
 
#include "company_base.h"
 
#include "story_base.h"
 
#include "command_func.h"
 
#include "string_func.h"
 

	
 
#include "widgets/goal_widget.h"
 

	
 
@@ -364,7 +365,7 @@ struct GoalQuestionWindow : public Windo
 
	GoalQuestionWindow(WindowDesc *desc, WindowNumber window_number, byte type, uint32 button_mask, const char *question) : Window(desc), type(type)
 
	{
 
		assert(type < GOAL_QUESTION_TYPE_COUNT);
 
		this->question = strdup(question);
 
		this->question = stredup(question);
 

	
 
		/* Figure out which buttons we have to enable. */
 
		uint bit;
src/group_cmd.cpp
Show inline comments
 
@@ -392,7 +392,7 @@ CommandCost CmdAlterGroup(TileIndex tile
 
			/* Delete the old name */
 
			free(g->name);
 
			/* Assign the new one */
 
			g->name = reset ? NULL : strdup(text);
 
			g->name = reset ? NULL : stredup(text);
 
		}
 
	} else {
 
		/* Set group parent */
src/hotkeys.cpp
Show inline comments
 
@@ -141,7 +141,7 @@ static void ParseHotkeys(Hotkey *hotkey,
 
 * by a '+'.
 
 * @param keycode The keycode to convert to a string.
 
 * @return A string representation of this keycode.
 
 * @note The return value is a static buffer, strdup the result before calling
 
 * @note The return value is a static buffer, stredup the result before calling
 
 *  this function again.
 
 */
 
static const char *KeycodeToString(uint16 keycode)
 
@@ -195,7 +195,7 @@ static const char *KeycodeToString(uint1
 
 * keycodes are attached to the hotkey they are split by a comma.
 
 * @param hotkey The keycodes of this hotkey need to be converted to a string.
 
 * @return A string representation of all keycodes.
 
 * @note The return value is a static buffer, strdup the result before calling
 
 * @note The return value is a static buffer, stredup the result before calling
 
 *  this function again.
 
 */
 
const char *SaveKeycodes(const Hotkey *hotkey)
src/ini_load.cpp
Show inline comments
 
@@ -49,7 +49,7 @@ IniItem::~IniItem()
 
void IniItem::SetValue(const char *value)
 
{
 
	free(this->value);
 
	this->value = strdup(value);
 
	this->value = stredup(value);
 
}
 

	
 
/**
 
@@ -168,7 +168,7 @@ IniGroup *IniLoadFile::GetGroup(const ch
 

	
 
	/* otherwise make a new one */
 
	IniGroup *group = new IniGroup(this, name, name + len - 1);
 
	group->comment = strdup("\n");
 
	group->comment = stredup("\n");
 
	return group;
 
}
 

	
src/misc_gui.cpp
Show inline comments
 
@@ -946,7 +946,7 @@ struct QueryStringWindow : public Window
 

	
 
		this->editbox.text.UpdateSize();
 

	
 
		if ((flags & QSF_ACCEPT_UNCHANGED) == 0) this->editbox.orig = strdup(this->editbox.text.buf);
 
		if ((flags & QSF_ACCEPT_UNCHANGED) == 0) this->editbox.orig = stredup(this->editbox.text.buf);
 

	
 
		this->querystrings[WID_QS_TEXT] = &this->editbox;
 
		this->editbox.caption = caption;
src/music/extmidi.cpp
Show inline comments
 
@@ -45,7 +45,7 @@ const char *MusicDriver_ExtMidi::Start(c
 
	const char *command = GetDriverParam(parm, "cmd");
 
	if (StrEmpty(command)) command = EXTERNAL_PLAYER;
 

	
 
	this->command = strdup(command);
 
	this->command = stredup(command);
 
	this->song[0] = '\0';
 
	this->pid = -1;
 
	return NULL;
src/network/core/tcp_http.h
Show inline comments
 
@@ -96,7 +96,7 @@ public:
 
			const char *data = NULL, int depth = 0) :
 
		TCPConnecter(address),
 
		callback(callback),
 
		url(strdup(url)),
 
		url(stredup(url)),
 
		data(data),
 
		depth(depth)
 
	{
src/network/network.cpp
Show inline comments
 
@@ -653,7 +653,7 @@ void NetworkRebuildHostList()
 
	_network_host_list.Clear();
 

	
 
	for (NetworkGameList *item = _network_game_list; item != NULL; item = item->next) {
 
		if (item->manually) *_network_host_list.Append() = strdup(item->address.GetAddressAsString(false));
 
		if (item->manually) *_network_host_list.Append() = stredup(item->address.GetAddressAsString(false));
 
	}
 
}
 

	
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -391,7 +391,7 @@ struct NetworkChatWindow : public Window
 
		item = 0;
 

	
 
		/* Copy the buffer so we can modify it without damaging the real data */
 
		pre_buf = (_chat_tab_completion_active) ? strdup(_chat_tab_completion_buf) : strdup(tb->buf);
 
		pre_buf = (_chat_tab_completion_active) ? stredup(_chat_tab_completion_buf) : stredup(tb->buf);
 

	
 
		tb_buf  = ChatTabCompletionFindText(pre_buf);
 
		tb_len  = strlen(tb_buf);
src/network/network_server.cpp
Show inline comments
 
@@ -2102,7 +2102,7 @@ uint NetworkServerKickOrBanIP(const char
 
				break;
 
			}
 
		}
 
		if (!contains) *_network_ban_list.Append() = strdup(ip);
 
		if (!contains) *_network_ban_list.Append() = stredup(ip);
 
	}
 

	
 
	uint n = 0;
src/newgrf.cpp
Show inline comments
 
@@ -6006,7 +6006,7 @@ static void CfgApply(ByteReader *buf)
 
static void DisableStaticNewGRFInfluencingNonStaticNewGRFs(GRFConfig *c)
 
{
 
	GRFError *error = DisableGrf(STR_NEWGRF_ERROR_STATIC_GRF_CAUSES_DESYNC, c);
 
	error->data = strdup(_cur.grfconfig->GetName());
 
	error->data = stredup(_cur.grfconfig->GetName());
 
}
 

	
 
/* Action 0x07
 
@@ -6369,7 +6369,7 @@ static void GRFLoadError(ByteReader *buf
 
			error->custom_message = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, message, NULL, SCC_RAW_STRING_POINTER);
 
		} else {
 
			grfmsg(7, "GRFLoadError: No custom message supplied.");
 
			error->custom_message = strdup("");
 
			error->custom_message = stredup("");
 
		}
 
	} else {
 
		error->message = msgstr[message_id];
 
@@ -6381,7 +6381,7 @@ static void GRFLoadError(ByteReader *buf
 
		error->data = TranslateTTDPatchCodes(_cur.grffile->grfid, lang, true, data);
 
	} else {
 
		grfmsg(7, "GRFLoadError: No message data supplied.");
 
		error->data = strdup("");
 
		error->data = stredup("");
 
	}
 

	
 
	/* Only two parameter numbers can be used in the string. */
 
@@ -6890,7 +6890,7 @@ static void GRFInhibit(ByteReader *buf)
 
		if (file != NULL && file != _cur.grfconfig) {
 
			grfmsg(2, "GRFInhibit: Deactivating file '%s'", file->filename);
 
			GRFError *error = DisableGrf(STR_NEWGRF_ERROR_FORCEFULLY_DISABLED, file);
 
			error->data = strdup(_cur.grfconfig->GetName());
 
			error->data = stredup(_cur.grfconfig->GetName());
 
		}
 
	}
 
}
 
@@ -7241,7 +7241,7 @@ static void TranslateGRFStrings(ByteRead
 

	
 
		char tmp[256];
 
		GetString(tmp, STR_NEWGRF_ERROR_AFTER_TRANSLATED_FILE, lastof(tmp));
 
		error->data = strdup(tmp);
 
		error->data = stredup(tmp);
 

	
 
		return;
 
	}
 
@@ -8182,7 +8182,7 @@ static void InitNewGRFFile(const GRFConf
 
 */
 
GRFFile::GRFFile(const GRFConfig *config)
 
{
 
	this->filename = strdup(config->filename);
 
	this->filename = stredup(config->filename);
 
	this->grfid = config->ident.grfid;
 

	
 
	/* Initialise local settings to defaults */
src/newgrf_config.cpp
Show inline comments
 
@@ -50,7 +50,7 @@ GRFConfig::GRFConfig(const char *filenam
 
	url(new GRFTextWrapper()),
 
	num_valid_params(lengthof(param))
 
{
 
	if (filename != NULL) this->filename = strdup(filename);
 
	if (filename != NULL) this->filename = stredup(filename);
 
	this->name->AddRef();
 
	this->info->AddRef();
 
	this->url->AddRef();
 
@@ -78,7 +78,7 @@ GRFConfig::GRFConfig(const GRFConfig &co
 
{
 
	MemCpyT<uint8>(this->original_md5sum, config.original_md5sum, lengthof(this->original_md5sum));
 
	MemCpyT<uint32>(this->param, config.param, lengthof(this->param));
 
	if (config.filename != NULL) this->filename = strdup(config.filename);
 
	if (config.filename != NULL) this->filename = stredup(config.filename);
 
	this->name->AddRef();
 
	this->info->AddRef();
 
	this->url->AddRef();
 
@@ -95,7 +95,7 @@ GRFConfig::GRFConfig(const GRFConfig &co
 
/** Cleanup a GRFConfig object. */
 
GRFConfig::~GRFConfig()
 
{
 
	/* GCF_COPY as in NOT strdupped/alloced the filename */
 
	/* GCF_COPY as in NOT stredupped/alloced the filename */
 
	if (!HasBit(this->flags, GCF_COPY)) {
 
		free(this->filename);
 
		delete this->error;
 
@@ -204,8 +204,8 @@ GRFError::GRFError(const GRFError &error
 
	message(error.message),
 
	severity(error.severity)
 
{
 
	if (error.custom_message != NULL) this->custom_message = strdup(error.custom_message);
 
	if (error.data           != NULL) this->data           = strdup(error.data);
 
	if (error.custom_message != NULL) this->custom_message = stredup(error.custom_message);
 
	if (error.data           != NULL) this->data           = stredup(error.data);
 
	memcpy(this->param_value, error.param_value, sizeof(this->param_value));
 
}
 

	
 
@@ -584,7 +584,7 @@ compatible_grf:
 
			 * already a local one, so there is no need to replace it. */
 
			if (!HasBit(c->flags, GCF_COPY)) {
 
				free(c->filename);
 
				c->filename = strdup(f->filename);
 
				c->filename = stredup(f->filename);
 
				memcpy(c->ident.md5sum, f->ident.md5sum, sizeof(c->ident.md5sum));
 
				c->name->Release();
 
				c->name = f->name;
src/newgrf_gui.cpp
Show inline comments
 
@@ -2036,9 +2036,9 @@ struct ScanProgressWindow : public Windo
 
		if (name == NULL) {
 
			char buf[256];
 
			GetString(buf, STR_NEWGRF_SCAN_ARCHIVES, lastof(buf));
 
			this->last_name = strdup(buf);
 
			this->last_name = stredup(buf);
 
		} else {
 
			this->last_name = strdup(name);
 
			this->last_name = stredup(name);
 
		}
 
		this->scanned = num;
 
		if (num > _settings_client.gui.last_newgrf_count) _settings_client.gui.last_newgrf_count = num;
src/newgrf_text.cpp
Show inline comments
 
@@ -231,7 +231,7 @@ struct UnmappedChoiceList : ZeroedMemory
 
			/* In case of a (broken) NewGRF without a default,
 
			 * assume an empty string. */
 
			grfmsg(1, "choice list misses default value");
 
			this->strings[0] = strdup("");
 
			this->strings[0] = stredup("");
 
		}
 

	
 
		char *d = old_d;
src/news_gui.cpp
Show inline comments
 
@@ -726,7 +726,7 @@ CommandCost CmdCustomNewsItem(TileIndex 
 
	if (company != INVALID_OWNER && company != _local_company) return CommandCost();
 

	
 
	if (flags & DC_EXEC) {
 
		char *news = strdup(text);
 
		char *news = stredup(text);
 
		SetDParamStr(0, news);
 
		AddNewsItem(STR_NEWS_CUSTOM_ITEM, type, NF_NORMAL, reftype1, p2, NR_NONE, UINT32_MAX, news);
 
	}
src/openttd.cpp
Show inline comments
 
@@ -444,7 +444,7 @@ struct AfterNewGRFScan : NewGRFScanCallb
 
#if defined(ENABLE_NETWORK)
 
		if (dedicated_host != NULL) {
 
			_network_bind_list.Clear();
 
			*_network_bind_list.Append() = strdup(dedicated_host);
 
			*_network_bind_list.Append() = stredup(dedicated_host);
 
		}
 
		if (dedicated_port != 0) _settings_client.network.server_port = dedicated_port;
 
#endif /* ENABLE_NETWORK */
 
@@ -563,23 +563,23 @@ int openttd_main(int argc, char *argv[])
 
	int i;
 
	while ((i = mgo.GetOpt()) != -1) {
 
		switch (i) {
 
		case 'I': free(graphics_set); graphics_set = strdup(mgo.opt); break;
 
		case 'S': free(sounds_set); sounds_set = strdup(mgo.opt); break;
 
		case 'M': free(music_set); music_set = strdup(mgo.opt); break;
 
		case 'm': free(musicdriver); musicdriver = strdup(mgo.opt); break;
 
		case 's': free(sounddriver); sounddriver = strdup(mgo.opt); break;
 
		case 'v': free(videodriver); videodriver = strdup(mgo.opt); break;
 
		case 'b': free(blitter); blitter = strdup(mgo.opt); break;
 
		case 'I': free(graphics_set); graphics_set = stredup(mgo.opt); break;
 
		case 'S': free(sounds_set); sounds_set = stredup(mgo.opt); break;
 
		case 'M': free(music_set); music_set = stredup(mgo.opt); break;
 
		case 'm': free(musicdriver); musicdriver = stredup(mgo.opt); break;
 
		case 's': free(sounddriver); sounddriver = stredup(mgo.opt); break;
 
		case 'v': free(videodriver); videodriver = stredup(mgo.opt); break;
 
		case 'b': free(blitter); blitter = stredup(mgo.opt); break;
 
#if defined(ENABLE_NETWORK)
 
		case 'D':
 
			free(musicdriver);
 
			free(sounddriver);
 
			free(videodriver);
 
			free(blitter);
 
			musicdriver = strdup("null");
 
			sounddriver = strdup("null");
 
			videodriver = strdup("dedicated");
 
			blitter = strdup("null");
 
			musicdriver = stredup("null");
 
			sounddriver = stredup("null");
 
			videodriver = stredup("dedicated");
 
			blitter = stredup("null");
 
			dedicated = true;
 
			SetDebugString("net=6");
 
			if (mgo.opt != NULL) {
 
@@ -667,7 +667,7 @@ int openttd_main(int argc, char *argv[])
 
			goto exit_noshutdown;
 
		}
 
		case 'G': scanner->generation_seed = atoi(mgo.opt); break;
 
		case 'c': _config_file = strdup(mgo.opt); break;
 
		case 'c': _config_file = stredup(mgo.opt); break;
 
		case 'x': scanner->save_config = false; break;
 
		case 'h':
 
			i = -2; // Force printing of help.
 
@@ -739,7 +739,7 @@ int openttd_main(int argc, char *argv[])
 
	InitWindowSystem();
 

	
 
	BaseGraphics::FindSets();
 
	if (graphics_set == NULL && BaseGraphics::ini_set != NULL) graphics_set = strdup(BaseGraphics::ini_set);
 
	if (graphics_set == NULL && BaseGraphics::ini_set != NULL) graphics_set = stredup(BaseGraphics::ini_set);
 
	if (!BaseGraphics::SetSet(graphics_set)) {
 
		if (!StrEmpty(graphics_set)) {
 
			BaseGraphics::SetSet(NULL);
 
@@ -755,7 +755,7 @@ int openttd_main(int argc, char *argv[])
 
	GfxInitPalettes();
 

	
 
	DEBUG(misc, 1, "Loading blitter...");
 
	if (blitter == NULL && _ini_blitter != NULL) blitter = strdup(_ini_blitter);
 
	if (blitter == NULL && _ini_blitter != NULL) blitter = stredup(_ini_blitter);
 
	_blitter_autodetected = StrEmpty(blitter);
 
	/* If we have a 32 bpp base set, try to select the 32 bpp blitter first, but only if we autoprobe the blitter. */
 
	if (!_blitter_autodetected || BaseGraphics::GetUsedSet() == NULL || BaseGraphics::GetUsedSet()->blitter == BLT_8BPP || BlitterFactory::SelectBlitter("32bpp-anim") == NULL) {
 
@@ -767,7 +767,7 @@ int openttd_main(int argc, char *argv[])
 
	}
 
	free(blitter);
 

	
 
	if (videodriver == NULL && _ini_videodriver != NULL) videodriver = strdup(_ini_videodriver);
 
	if (videodriver == NULL && _ini_videodriver != NULL) videodriver = stredup(_ini_videodriver);
 
	_video_driver = (VideoDriver*)DriverFactoryBase::SelectDriver(videodriver, Driver::DT_VIDEO);
 
	if (_video_driver == NULL) {
 
		StrEmpty(videodriver) ?
 
@@ -810,7 +810,7 @@ int openttd_main(int argc, char *argv[])
 
	InitializeScreenshotFormats();
 

	
 
	BaseSounds::FindSets();
 
	if (sounds_set == NULL && BaseSounds::ini_set != NULL) sounds_set = strdup(BaseSounds::ini_set);
 
	if (sounds_set == NULL && BaseSounds::ini_set != NULL) sounds_set = stredup(BaseSounds::ini_set);
 
	if (!BaseSounds::SetSet(sounds_set)) {
 
		if (StrEmpty(sounds_set) || !BaseSounds::SetSet(NULL)) {
 
			usererror("Failed to find a sounds set. Please acquire a sounds set for OpenTTD. See section 4.1 of readme.txt.");
 
@@ -823,7 +823,7 @@ int openttd_main(int argc, char *argv[])
 
	free(sounds_set);
 

	
 
	BaseMusic::FindSets();
 
	if (music_set == NULL && BaseMusic::ini_set != NULL) music_set = strdup(BaseMusic::ini_set);
 
	if (music_set == NULL && BaseMusic::ini_set != NULL) music_set = stredup(BaseMusic::ini_set);
 
	if (!BaseMusic::SetSet(music_set)) {
 
		if (StrEmpty(music_set) || !BaseMusic::SetSet(NULL)) {
 
			usererror("Failed to find a music set. Please acquire a music set for OpenTTD. See section 4.1 of readme.txt.");
 
@@ -835,7 +835,7 @@ int openttd_main(int argc, char *argv[])
 
	}
 
	free(music_set);
 

	
 
	if (sounddriver == NULL && _ini_sounddriver != NULL) sounddriver = strdup(_ini_sounddriver);
 
	if (sounddriver == NULL && _ini_sounddriver != NULL) sounddriver = stredup(_ini_sounddriver);
 
	_sound_driver = (SoundDriver*)DriverFactoryBase::SelectDriver(sounddriver, Driver::DT_SOUND);
 
	if (_sound_driver == NULL) {
 
		StrEmpty(sounddriver) ?
 
@@ -844,7 +844,7 @@ int openttd_main(int argc, char *argv[])
 
	}
 
	free(sounddriver);
 

	
 
	if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = strdup(_ini_musicdriver);
 
	if (musicdriver == NULL && _ini_musicdriver != NULL) musicdriver = stredup(_ini_musicdriver);
 
	_music_driver = (MusicDriver*)DriverFactoryBase::SelectDriver(musicdriver, Driver::DT_MUSIC);
 
	if (_music_driver == NULL) {
 
		StrEmpty(musicdriver) ?
 
@@ -1157,7 +1157,7 @@ void SwitchToMode(SwitchMode new_mode)
 
			LoadIntroGame();
 
			if (BaseSounds::ini_set == NULL && BaseSounds::GetUsedSet()->fallback) {
 
				ShowErrorMessage(STR_WARNING_FALLBACK_SOUNDSET, INVALID_STRING_ID, WL_CRITICAL);
 
				BaseSounds::ini_set = strdup(BaseSounds::GetUsedSet()->name);
 
				BaseSounds::ini_set = stredup(BaseSounds::GetUsedSet()->name);
 
			}
 
			break;
 

	
src/os/windows/win32.cpp
Show inline comments
 
@@ -435,7 +435,7 @@ int APIENTRY WinMain(HINSTANCE hInstance
 
	/* Convert the command line to UTF-8. We need a dedicated buffer
 
	 * for this because argv[] points into this buffer and this needs to
 
	 * be available between subsequent calls to FS2OTTD(). */
 
	char *cmdline = strdup(FS2OTTD(GetCommandLine()));
 
	char *cmdline = stredup(FS2OTTD(GetCommandLine()));
 

	
 
#if defined(_DEBUG)
 
	CreateConsole();
 
@@ -498,7 +498,7 @@ void DetermineBasePaths(const char *exe)
 
		AppendPathSeparator(tmp, lastof(tmp));
 
		strecat(tmp, PERSONAL_DIR, lastof(tmp));
 
		AppendPathSeparator(tmp, lastof(tmp));
 
		_searchpaths[SP_PERSONAL_DIR] = strdup(tmp);
 
		_searchpaths[SP_PERSONAL_DIR] = stredup(tmp);
 
	} else {
 
		_searchpaths[SP_PERSONAL_DIR] = NULL;
 
	}
 
@@ -508,7 +508,7 @@ void DetermineBasePaths(const char *exe)
 
		AppendPathSeparator(tmp, lastof(tmp));
 
		strecat(tmp, PERSONAL_DIR, lastof(tmp));
 
		AppendPathSeparator(tmp, lastof(tmp));
 
		_searchpaths[SP_SHARED_DIR] = strdup(tmp);
 
		_searchpaths[SP_SHARED_DIR] = stredup(tmp);
 
	} else {
 
		_searchpaths[SP_SHARED_DIR] = NULL;
 
	}
 
@@ -520,7 +520,7 @@ void DetermineBasePaths(const char *exe)
 
	/* Get the path to working directory of OpenTTD */
 
	getcwd(tmp, lengthof(tmp));
 
	AppendPathSeparator(tmp, lastof(tmp));
 
	_searchpaths[SP_WORKING_DIR] = strdup(tmp);
 
	_searchpaths[SP_WORKING_DIR] = stredup(tmp);
 

	
 
	if (!GetModuleFileName(NULL, path, lengthof(path))) {
 
		DEBUG(misc, 0, "GetModuleFileName failed (%lu)\n", GetLastError());
 
@@ -535,7 +535,7 @@ void DetermineBasePaths(const char *exe)
 
			strecpy(tmp, convert_from_fs(exec_dir, tmp, lengthof(tmp)), lastof(tmp));
 
			char *s = strrchr(tmp, PATHSEPCHAR);
 
			*(s + 1) = '\0';
 
			_searchpaths[SP_BINARY_DIR] = strdup(tmp);
 
			_searchpaths[SP_BINARY_DIR] = stredup(tmp);
 
		}
 
	}
 

	
src/osk_gui.cpp
Show inline comments
 
@@ -59,7 +59,7 @@ struct OskWindow : public Window {
 
		this->querystrings[WID_OSK_TEXT] = this->qs;
 

	
 
		/* make a copy in case we need to reset later */
 
		this->orig_str_buf = strdup(this->qs->text.buf);
 
		this->orig_str_buf = stredup(this->qs->text.buf);
 

	
 
		this->InitNested(0);
 
		this->SetFocusedWidget(WID_OSK_TEXT);
 
@@ -430,7 +430,7 @@ void UpdateOSKOriginalText(const Window 
 
	if (osk == NULL || osk->parent != parent || osk->text_btn != button) return;
 

	
 
	free(osk->orig_str_buf);
 
	osk->orig_str_buf = strdup(osk->qs->text.buf);
 
	osk->orig_str_buf = stredup(osk->qs->text.buf);
 

	
 
	osk->SetDirty();
 
}
src/safeguards.h
Show inline comments
 
@@ -31,11 +31,11 @@
 
#define realloc   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use stredup instead. */
 
//#define strdup    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strdup    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strndup   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use strecpy instead. */
 
//#define strcpy    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
#define strcpy    SAFEGUARD_DO_NOT_USE_THIS_METHOD
 
//#define strncpy   SAFEGUARD_DO_NOT_USE_THIS_METHOD
 

	
 
/* Use strecat instead. */
src/saveload/engine_sl.cpp
Show inline comments
 
@@ -12,6 +12,7 @@
 
#include "../stdafx.h"
 
#include "saveload_internal.h"
 
#include "../engine_base.h"
 
#include "../string_func.h"
 
#include <map>
 

	
 
#include "../safeguards.h"
 
@@ -107,7 +108,7 @@ void CopyTempEngineData()
 
		e->preview_company     = se->preview_company;
 
		e->preview_wait        = se->preview_wait;
 
		e->company_avail       = se->company_avail;
 
		if (se->name != NULL) e->name = strdup(se->name);
 
		if (se->name != NULL) e->name = stredup(se->name);
 
	}
 

	
 
	/* Get rid of temporary data */
src/saveload/game_sl.cpp
Show inline comments
 
@@ -153,7 +153,7 @@ static void Load_GSTR()
 
		LanguageStrings *ls = new LanguageStrings(_game_saveload_string != NULL ? _game_saveload_string : "");
 
		for (uint i = 0; i < _game_saveload_strings; i++) {
 
			SlObject(NULL, _game_language_string);
 
			*ls->lines.Append() = strdup(_game_saveload_string != NULL ? _game_saveload_string : "");
 
			*ls->lines.Append() = stredup(_game_saveload_string != NULL ? _game_saveload_string : "");
 
		}
 

	
 
		*_current_data->raw_strings.Append() = ls;
src/saveload/saveload.cpp
Show inline comments
 
@@ -527,11 +527,11 @@ void NORETURN SlError(StringID string, c
 
	if (_sl.action == SLA_LOAD_CHECK) {
 
		_load_check_data.error = string;
 
		free(_load_check_data.error_data);
 
		_load_check_data.error_data = (extra_msg == NULL) ? NULL : strdup(extra_msg);
 
		_load_check_data.error_data = (extra_msg == NULL) ? NULL : stredup(extra_msg);
 
	} else {
 
		_sl.error_str = string;
 
		free(_sl.extra_msg);
 
		_sl.extra_msg = (extra_msg == NULL) ? NULL : strdup(extra_msg);
 
		_sl.extra_msg = (extra_msg == NULL) ? NULL : stredup(extra_msg);
 
	}
 

	
 
	/* We have to NULL all pointers here; we might be in a state where
src/saveload/strings_sl.cpp
Show inline comments
 
@@ -94,10 +94,10 @@ char *CopyFromOldName(StringID id)
 
		/* Terminate the new string and copy it back to the name array */
 
		*strto = '\0';
 

	
 
		return strdup(tmp);
 
		return stredup(tmp);
 
	} else {
 
		/* Name will already be in UTF-8. */
 
		return strdup(&_old_name_array[LEN_OLD_STRINGS * GB(id, 0, 9)]);
 
		return stredup(&_old_name_array[LEN_OLD_STRINGS * GB(id, 0, 9)]);
 
	}
 
}
 

	
src/script/api/script_controller.cpp
Show inline comments
 
@@ -154,7 +154,7 @@ ScriptController::~ScriptController()
 
		sq_newslot(vm, -3, SQFalse);
 
		sq_pop(vm, 1);
 

	
 
		controller->loaded_library[strdup(library_name)] = strdup(fake_class);
 
		controller->loaded_library[stredup(library_name)] = stredup(fake_class);
 
	}
 

	
 
	/* Find the real class inside the fake class (like 'sets.Vector') */
src/script/api/script_error.cpp
Show inline comments
 
@@ -12,6 +12,7 @@
 
#include "../../stdafx.h"
 
#include "script_error.hpp"
 
#include "../../core/bitmath_func.hpp"
 
#include "../../string_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 
@@ -25,7 +26,7 @@ ScriptError::ScriptErrorMapString Script
 

	
 
/* static */ char *ScriptError::GetLastErrorString()
 
{
 
	return strdup((*error_map_string.find(ScriptError::GetLastError())).second);
 
	return stredup((*error_map_string.find(ScriptError::GetLastError())).second);
 
}
 

	
 
/* static */ ScriptErrorType ScriptError::StringToError(StringID internal_string_id)
src/script/api/script_event_types.cpp
Show inline comments
 
@@ -17,6 +17,7 @@
 
#include "../../settings_type.h"
 
#include "../../engine_base.h"
 
#include "../../articulated_vehicles.h"
 
#include "../../string_func.h"
 
#include "table/strings.h"
 

	
 
#include "../../safeguards.h"
 
@@ -119,6 +120,17 @@ bool ScriptEventCompanyAskMerger::Accept
 
	return ScriptObject::DoCommand(0, this->owner, 0, CMD_BUY_COMPANY);
 
}
 

	
 
ScriptEventAdminPort::ScriptEventAdminPort(const char *json) :
 
		ScriptEvent(ET_ADMIN_PORT),
 
		json(stredup(json))
 
{
 
}
 

	
 
ScriptEventAdminPort::~ScriptEventAdminPort()
 
{
 
	free(this->json);
 
}
 

	
 
#define SKIP_EMPTY(p) while (*(p) == ' ' || *(p) == '\n' || *(p) == '\r') (p)++;
 
#define RETURN_ERROR(stack) { ScriptLog::Error("Received invalid JSON data from AdminPort."); if (stack != 0) sq_pop(vm, stack); return NULL; }
 

	
src/script/api/script_event_types.hpp
Show inline comments
 
@@ -839,15 +839,8 @@ public:
 
	/**
 
	 * @param json The JSON string which got sent.
 
	 */
 
	ScriptEventAdminPort(const char *json) :
 
		ScriptEvent(ET_ADMIN_PORT),
 
		json(strdup(json))
 
	{}
 

	
 
	~ScriptEventAdminPort()
 
	{
 
		free(this->json);
 
	}
 
	ScriptEventAdminPort(const char *json);
 
	~ScriptEventAdminPort();
 

	
 
	/**
 
	 * Convert an ScriptEvent to the real instance.
src/script/api/script_log.cpp
Show inline comments
 
@@ -14,6 +14,7 @@
 
#include "../../core/alloc_func.hpp"
 
#include "../../debug.h"
 
#include "../../window_func.h"
 
#include "../../string_func.h"
 

	
 
#include "../../safeguards.h"
 

	
 
@@ -53,7 +54,7 @@
 

	
 
	/* Free last message, and write new message */
 
	free(log->lines[log->pos]);
 
	log->lines[log->pos] = strdup(message);
 
	log->lines[log->pos] = stredup(message);
 
	log->type[log->pos] = level;
 

	
 
	/* Cut string after first \n */
src/script/api/script_object.cpp
Show inline comments
 
@@ -264,7 +264,7 @@ ScriptObject::ActiveInstance::~ActiveIns
 
	char buffer[64];
 
	::GetString(buffer, string, lastof(buffer));
 
	::str_validate(buffer, lastof(buffer), SVS_NONE);
 
	return ::strdup(buffer);
 
	return ::stredup(buffer);
 
}
 

	
 
/* static */ void ScriptObject::SetCallbackVariable(int index, int value)
src/script/api/script_text.cpp
Show inline comments
 
@@ -19,6 +19,16 @@
 

	
 
#include "../../safeguards.h"
 

	
 
RawText::RawText(const char *text) : text(stredup(text))
 
{
 
}
 

	
 
RawText::~RawText()
 
{
 
	free(this->text);
 
}
 

	
 

	
 
ScriptText::ScriptText(HSQUIRRELVM vm) :
 
	ZeroedMemoryAllocator()
 
{
 
@@ -73,7 +83,7 @@ SQInteger ScriptText::_SetParam(int para
 
			const SQChar *value;
 
			sq_getstring(vm, -1, &value);
 

	
 
			this->params[parameter] = strdup(SQ2OTTD(value));
 
			this->params[parameter] = stredup(SQ2OTTD(value));
 
			ValidateString(this->params[parameter]);
 
			break;
 
		}
src/script/api/script_text.hpp
Show inline comments
 
@@ -42,9 +42,8 @@ public:
 
 */
 
class RawText : public Text {
 
public:
 
	RawText(const char *text) :
 
	  text(strdup(text)) {}
 
	~RawText() { free(this->text); }
 
	RawText(const char *text);
 
	~RawText();
 

	
 
	/* virtual */ const char *GetEncodedText() { return this->text; }
 
private:
src/script/script_config.cpp
Show inline comments
 
@@ -21,7 +21,7 @@
 
void ScriptConfig::Change(const char *name, int version, bool force_exact_match, bool is_random)
 
{
 
	free(this->name);
 
	this->name = (name == NULL) ? NULL : strdup(name);
 
	this->name = (name == NULL) ? NULL : stredup(name);
 
	this->info = (name == NULL) ? NULL : this->FindInfo(this->name, version, force_exact_match);
 
	this->version = (info == NULL) ? -1 : info->GetVersion();
 
	this->is_random = is_random;
 
@@ -45,14 +45,14 @@ void ScriptConfig::Change(const char *na
 

	
 
ScriptConfig::ScriptConfig(const ScriptConfig *config)
 
{
 
	this->name = (config->name == NULL) ? NULL : strdup(config->name);
 
	this->name = (config->name == NULL) ? NULL : stredup(config->name);
 
	this->info = config->info;
 
	this->version = config->version;
 
	this->config_list = NULL;
 
	this->is_random = config->is_random;
 

	
 
	for (SettingValueList::const_iterator it = config->settings.begin(); it != config->settings.end(); it++) {
 
		this->settings[strdup((*it).first)] = (*it).second;
 
		this->settings[stredup((*it).first)] = (*it).second;
 
	}
 
	this->AddRandomDeviation();
 
}
 
@@ -117,7 +117,7 @@ void ScriptConfig::SetSetting(const char
 
	if (it != this->settings.end()) {
 
		(*it).second = value;
 
	} else {
 
		this->settings[strdup(name)] = value;
 
		this->settings[stredup(name)] = value;
 
	}
 
}
 

	
 
@@ -160,7 +160,7 @@ int ScriptConfig::GetVersion() const
 

	
 
void ScriptConfig::StringToSettings(const char *value)
 
{
 
	char *value_copy = strdup(value);
 
	char *value_copy = stredup(value);
 
	char *s = value_copy;
 

	
 
	while (s != NULL) {
src/script/script_info.cpp
Show inline comments
 
@@ -83,9 +83,9 @@ bool ScriptInfo::CheckMethod(const char 
 
	}
 

	
 
	/* Get location information of the scanner */
 
	info->main_script = strdup(info->scanner->GetMainScript());
 
	info->main_script = stredup(info->scanner->GetMainScript());
 
	const char *tar_name = info->scanner->GetTarFile();
 
	if (tar_name != NULL) info->tar_file = strdup(tar_name);
 
	if (tar_name != NULL) info->tar_file = stredup(tar_name);
 

	
 
	/* Cache the data the info file gives us. */
 
	if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAuthor", &info->author, MAX_GET_OPS)) return SQ_ERROR;
 
@@ -133,7 +133,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRR
 
		if (strcmp(key, "name") == 0) {
 
			const SQChar *sqvalue;
 
			if (SQ_FAILED(sq_getstring(vm, -1, &sqvalue))) return SQ_ERROR;
 
			char *name = strdup(SQ2OTTD(sqvalue));
 
			char *name = stredup(SQ2OTTD(sqvalue));
 
			char *s;
 
			ValidateString(name);
 

	
 
@@ -146,7 +146,7 @@ SQInteger ScriptInfo::AddSetting(HSQUIRR
 
		} else if (strcmp(key, "description") == 0) {
 
			const SQChar *sqdescription;
 
			if (SQ_FAILED(sq_getstring(vm, -1, &sqdescription))) return SQ_ERROR;
 
			config.description = strdup(SQ2OTTD(sqdescription));
 
			config.description = stredup(SQ2OTTD(sqdescription));
 
			ValidateString(config.description);
 
			items |= 0x002;
 
		} else if (strcmp(key, "min_value") == 0) {
 
@@ -264,8 +264,8 @@ SQInteger ScriptInfo::AddLabels(HSQUIRRE
 
		const char *label = SQ2OTTD(sq_label);
 
		ValidateString(label);
 

	
 
		/* !Contains() prevents strdup from leaking. */
 
		if (!config->labels->Contains(key)) config->labels->Insert(key, strdup(label));
 
		/* !Contains() prevents stredup from leaking. */
 
		if (!config->labels->Contains(key)) config->labels->Insert(key, stredup(label));
 

	
 
		sq_pop(vm, 2);
 
	}
src/script/script_scanner.cpp
Show inline comments
 
@@ -29,12 +29,12 @@
 
bool ScriptScanner::AddFile(const char *filename, size_t basepath_length, const char *tar_filename)
 
{
 
	free(this->main_script);
 
	this->main_script = strdup(filename);
 
	this->main_script = stredup(filename);
 
	if (this->main_script == NULL) return false;
 

	
 
	free(this->tar_file);
 
	if (tar_filename != NULL) {
 
		this->tar_file = strdup(tar_filename);
 
		this->tar_file = stredup(tar_filename);
 
		if (this->tar_file == NULL) return false;
 
	} else {
 
		this->tar_file = NULL;
 
@@ -150,13 +150,13 @@ void ScriptScanner::RegisterScript(Scrip
 
		return;
 
	}
 

	
 
	this->info_list[strdup(script_name)] = info;
 
	this->info_list[stredup(script_name)] = info;
 

	
 
	if (!info->IsDeveloperOnly() || _settings_client.gui.ai_developer_tools) {
 
		/* Add the script to the 'unique' script list, where only the highest version
 
		 *  of the script is registered. */
 
		if (this->info_single_list.find(script_original_name) == this->info_single_list.end()) {
 
			this->info_single_list[strdup(script_original_name)] = info;
 
			this->info_single_list[stredup(script_original_name)] = info;
 
		} else if (this->info_single_list[script_original_name]->GetVersion() < info->GetVersion()) {
 
			this->info_single_list[script_original_name] = info;
 
		}
src/script/squirrel.cpp
Show inline comments
 
@@ -260,7 +260,7 @@ bool Squirrel::CallStringMethodStrdup(HS
 
	HSQOBJECT ret;
 
	if (!this->CallMethod(instance, method_name, &ret, suspend)) return false;
 
	if (ret._type != OT_STRING) return false;
 
	*res = strdup(ObjectToString(&ret));
 
	*res = stredup(ObjectToString(&ret));
 
	ValidateString(*res);
 
	return true;
 
}
src/script/squirrel_helper.hpp
Show inline comments
 
@@ -26,7 +26,7 @@ template <class CL, ScriptType ST> const
 
namespace SQConvert {
 
	/**
 
	 * Pointers assigned to this class will be free'd when this instance
 
	 *  comes out of scope. Useful to make sure you can use strdup(),
 
	 *  comes out of scope. Useful to make sure you can use stredup(),
 
	 *  without leaking memory.
 
	 */
 
	struct SQAutoFreePointers : SmallVector<void *, 1> {
 
@@ -113,7 +113,7 @@ namespace SQConvert {
 

	
 
		const SQChar *tmp;
 
		sq_getstring(vm, -1, &tmp);
 
		char *tmp_str = strdup(SQ2OTTD(tmp));
 
		char *tmp_str = stredup(SQ2OTTD(tmp));
 
		sq_poptop(vm);
 
		*ptr->Append() = (void *)tmp_str;
 
		str_validate(tmp_str, tmp_str + strlen(tmp_str));
src/script/squirrel_std.cpp
Show inline comments
 
@@ -16,11 +16,13 @@
 
#include "squirrel_std.hpp"
 
#include "../core/alloc_func.hpp"
 
#include "../core/math_func.hpp"
 
#include "../string_func.h"
 

	
 
/* Due to the different characters for Squirrel, the scstrcat might be a simple
 
 * strcat which triggers the safeguard. But it isn't always a simple strcat. */
 
#include "../safeguards.h"
 
#undef strcat
 
#undef strdup
 

	
 

	
 
SQInteger SquirrelStd::min(HSQUIRRELVM vm)
 
@@ -71,7 +73,7 @@ SQInteger SquirrelStd::require(HSQUIRREL
 
	real_filename = ReallocT(real_filename, scstrlen(real_filename) + scstrlen(filename) + 1);
 
	scstrcat(real_filename, filename);
 
	/* Tars dislike opening files with '/' on Windows.. so convert it to '\\' ;) */
 
	char *filen = strdup(SQ2OTTD(real_filename));
 
	char *filen = stredup(SQ2OTTD(real_filename));
 
#if (PATHSEPCHAR != '/')
 
	for (char *n = filen; *n != '\0'; n++) if (*n == '/') *n = PATHSEPCHAR;
 
#endif
src/settings.cpp
Show inline comments
 
@@ -532,7 +532,7 @@ static void IniLoadSettings(IniFile *ini
 
					case SLE_VAR_STR:
 
					case SLE_VAR_STRQ:
 
						free(*(char**)ptr);
 
						*(char**)ptr = p == NULL ? NULL : strdup((const char*)p);
 
						*(char**)ptr = p == NULL ? NULL : stredup((const char*)p);
 
						break;
 

	
 
					case SLE_VAR_CHAR: if (p != NULL) *(char *)ptr = *(const char *)p; break;
 
@@ -687,7 +687,7 @@ static void IniSaveSettings(IniFile *ini
 

	
 
		/* The value is different, that means we have to write it to the ini */
 
		free(item->value);
 
		item->value = strdup(buf);
 
		item->value = stredup(buf);
 
	}
 
}
 

	
 
@@ -709,7 +709,7 @@ static void IniLoadSettingList(IniFile *
 
	list->Clear();
 

	
 
	for (const IniItem *item = group->item; item != NULL; item = item->next) {
 
		if (item->name != NULL) *list->Append() = strdup(item->name);
 
		if (item->name != NULL) *list->Append() = stredup(item->name);
 
	}
 
}
 

	
 
@@ -1659,7 +1659,7 @@ void GetGRFPresetList(GRFPresetList *lis
 
	IniGroup *group;
 
	for (group = ini->group; group != NULL; group = group->next) {
 
		if (strncmp(group->name, "preset-", 7) == 0) {
 
			*list->Append() = strdup(group->name + 7);
 
			*list->Append() = stredup(group->name + 7);
 
		}
 
	}
 

	
 
@@ -1929,7 +1929,7 @@ bool SetSettingValue(uint index, const c
 
	if (GetVarMemType(sd->save.conv) == SLE_VAR_STRQ) {
 
		char **var = (char**)GetVariableAddress((_game_mode == GM_MENU || force_newgame) ? &_settings_newgame : &_settings_game, &sd->save);
 
		free(*var);
 
		*var = strcmp(value, "(null)") == 0 ? NULL : strdup(value);
 
		*var = strcmp(value, "(null)") == 0 ? NULL : stredup(value);
 
	} else {
 
		char *var = (char*)GetVariableAddress(NULL, &sd->save);
 
		strecpy(var, value, &var[sd->save.length - 1]);
src/settings_gui.cpp
Show inline comments
 
@@ -460,7 +460,7 @@ struct GameOptionsWindow : Window {
 
			const char *name = T::GetSet(index)->name;
 

	
 
			free(T::ini_set);
 
			T::ini_set = strdup(name);
 
			T::ini_set = stredup(name);
 

	
 
			T::SetSet(name);
 
			this->reload = true;
src/signs_cmd.cpp
Show inline comments
 
@@ -55,7 +55,7 @@ CommandCost CmdPlaceSign(TileIndex tile,
 
		si->y = y;
 
		si->z = GetSlopePixelZ(x, y);
 
		if (!StrEmpty(text)) {
 
			si->name = strdup(text);
 
			si->name = stredup(text);
 
		}
 
		si->UpdateVirtCoord();
 
		InvalidateWindowData(WC_SIGN_LIST, 0, 0);
 
@@ -90,7 +90,7 @@ CommandCost CmdRenameSign(TileIndex tile
 
			/* Delete the old name */
 
			free(si->name);
 
			/* Assign the new one */
 
			si->name = strdup(text);
 
			si->name = stredup(text);
 
			if (_game_mode != GM_EDITOR) si->owner = _current_company;
 

	
 
			si->UpdateVirtCoord();
src/station_cmd.cpp
Show inline comments
 
@@ -3727,7 +3727,7 @@ CommandCost CmdRenameStation(TileIndex t
 

	
 
	if (flags & DC_EXEC) {
 
		free(st->name);
 
		st->name = reset ? NULL : strdup(text);
 
		st->name = reset ? NULL : stredup(text);
 

	
 
		st->UpdateVirtCoord();
 
		InvalidateWindowData(WC_STATION_LIST, st->owner, 1);
src/stdafx.h
Show inline comments
 
@@ -281,7 +281,7 @@
 
#endif
 

	
 
#if defined(WINCE)
 
	#define strdup _strdup
 
	#define stredup _stredup
 
#endif /* WINCE */
 

	
 
/* NOTE: the string returned by these functions is only valid until the next
src/story.cpp
Show inline comments
 
@@ -81,10 +81,10 @@ static void UpdateElement(StoryPageEleme
 
{
 
	switch (pe.type) {
 
		case SPET_TEXT:
 
			pe.text = strdup(text);
 
			pe.text = stredup(text);
 
			break;
 
		case SPET_LOCATION:
 
			pe.text = strdup(text);
 
			pe.text = stredup(text);
 
			pe.referenced_id = tile;
 
			break;
 
		case SPET_GOAL:
 
@@ -126,7 +126,7 @@ CommandCost CmdCreateStoryPage(TileIndex
 
		if (StrEmpty(text)) {
 
			s->title = NULL;
 
		} else {
 
			s->title = strdup(text);
 
			s->title = stredup(text);
 
		}
 

	
 
		InvalidateWindowClassesData(WC_STORY_BOOK, -1);
 
@@ -243,7 +243,7 @@ CommandCost CmdSetStoryPageTitle(TileInd
 
		if (StrEmpty(text)) {
 
			p->title = NULL;
 
		} else {
 
			p->title = strdup(text);
 
			p->title = stredup(text);
 
		}
 

	
 
		InvalidateWindowClassesData(WC_STORY_BOOK, page_id);
src/strgen/strgen.cpp
Show inline comments
 
@@ -247,7 +247,7 @@ struct FileWriter {
 
	 */
 
	FileWriter(const char *filename)
 
	{
 
		this->filename = strdup(filename);
 
		this->filename = stredup(filename);
 
		this->fh = fopen(this->filename, "wb");
 

	
 
		if (this->fh == NULL) {
 
@@ -285,7 +285,7 @@ struct HeaderFileWriter : HeaderWriter, 
 
	 * @param filename The file to open.
 
	 */
 
	HeaderFileWriter(const char *filename) : FileWriter("tmp.xxx"),
 
		real_filename(strdup(filename)), prev(0)
 
		real_filename(stredup(filename)), prev(0)
 
	{
 
		fprintf(this->fh, "/* This file is automatically generated. Do not modify */\n\n");
 
		fprintf(this->fh, "#ifndef TABLE_STRINGS_H\n");
src/strgen/strgen_base.cpp
Show inline comments
 
@@ -40,7 +40,7 @@ static const CmdStruct *ParseCommandStri
 
 * @param next    The next chained case.
 
 */
 
Case::Case(int caseidx, const char *string, Case *next) :
 
		caseidx(caseidx), string(strdup(string)), next(next)
 
		caseidx(caseidx), string(stredup(string)), next(next)
 
{
 
}
 

	
 
@@ -59,7 +59,7 @@ Case::~Case()
 
 * @param line    The line this string was found on.
 
 */
 
LangString::LangString(const char *name, const char *english, int index, int line) :
 
		name(strdup(name)), english(strdup(english)), translated(NULL),
 
		name(stredup(name)), english(stredup(english)), translated(NULL),
 
		hash_next(0), index(index), line(line), translated_case(NULL)
 
{
 
}
 
@@ -577,7 +577,7 @@ static const CmdStruct *ParseCommandStri
 
 * @param translation Are we reading a translation?
 
 */
 
StringReader::StringReader(StringData &data, const char *file, bool master, bool translation) :
 
		data(data), file(strdup(file)), master(master), translation(translation)
 
		data(data), file(stredup(file)), master(master), translation(translation)
 
{
 
}
 

	
 
@@ -614,7 +614,7 @@ static void ExtractCommandString(ParsedC
 
		} else if (!(ar->flags & C_DONTCOUNT)) { // Ignore some of them
 
			if (p->np >= lengthof(p->pairs)) strgen_fatal("too many commands in string, max " PRINTF_SIZE, lengthof(p->pairs));
 
			p->pairs[p->np].a = ar;
 
			p->pairs[p->np].v = param[0] != '\0' ? strdup(param) : "";
 
			p->pairs[p->np].v = param[0] != '\0' ? stredup(param) : "";
 
			p->np++;
 
		}
 
	}
 
@@ -778,7 +778,7 @@ void StringReader::HandleString(char *st
 
		if (casep != NULL) {
 
			ent->translated_case = new Case(ResolveCaseName(casep, strlen(casep)), s, ent->translated_case);
 
		} else {
 
			ent->translated = strdup(s);
 
			ent->translated = stredup(s);
 
			/* If the string was translated, use the line from the
 
			 * translated language so errors in the translated file
 
			 * are properly referenced to. */
src/strings.cpp
Show inline comments
 
@@ -165,7 +165,7 @@ void CopyOutDParam(uint64 *dst, const ch
 
	MemCpyT(dst, _global_string_params.GetPointerToOffset(0), num);
 
	for (int i = 0; i < num; i++) {
 
		if (_global_string_params.HasTypeInformation() && _global_string_params.GetTypeAtOffset(i) == SCC_RAW_STRING_POINTER) {
 
			strings[i] = strdup((const char *)(size_t)_global_string_params.GetParam(i));
 
			strings[i] = stredup((const char *)(size_t)_global_string_params.GetParam(i));
 
			dst[i] = (size_t)strings[i];
 
		} else {
 
			strings[i] = NULL;
 
@@ -889,7 +889,7 @@ static char *FormatString(char *buff, co
 

	
 
						sub_args.SetParam(i++, param);
 
					} else {
 
						char *g = strdup(s);
 
						char *g = stredup(s);
 
						g[p - s] = '\0';
 

	
 
						sub_args_need_free[i] = true;
 
@@ -2124,7 +2124,7 @@ void CheckForMissingGlyphs(bool base_fon
 
		 * properly we have to set the colour of the string, otherwise we end up with a lot of artifacts.
 
		 * The colour 'character' might change in the future, so for safety we just Utf8 Encode it into
 
		 * the string, which takes exactly three characters, so it replaces the "XXX" with the colour marker. */
 
		static char *err_str = strdup("XXXThe current font is missing some of the characters used in the texts for this language. Read the readme to see how to solve this.");
 
		static char *err_str = stredup("XXXThe current font is missing some of the characters used in the texts for this language. Read the readme to see how to solve this.");
 
		Utf8Encode(err_str, SCC_YELLOW);
 
		SetDParamStr(0, err_str);
 
		ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_WARNING);
 
@@ -2152,7 +2152,7 @@ void CheckForMissingGlyphs(bool base_fon
 
	 * the colour marker.
 
	 */
 
	if (_current_text_dir != TD_LTR) {
 
		static char *err_str = strdup("XXXThis version of OpenTTD does not support right-to-left languages. Recompile with icu enabled.");
 
		static char *err_str = stredup("XXXThis version of OpenTTD does not support right-to-left languages. Recompile with icu enabled.");
 
		Utf8Encode(err_str, SCC_YELLOW);
 
		SetDParamStr(0, err_str);
 
		ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, WL_ERROR);
src/subsidy.cpp
Show inline comments
 
@@ -24,6 +24,7 @@
 
#include "core/random_func.hpp"
 
#include "game/game.hpp"
 
#include "command_func.h"
 
#include "string_func.h"
 

	
 
#include "table/strings.h"
 

	
 
@@ -47,7 +48,7 @@ void Subsidy::AwardTo(CompanyID company)
 
	SetDParam(0, company);
 
	GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
 

	
 
	char *cn = strdup(company_name);
 
	char *cn = stredup(company_name);
 

	
 
	/* Add a news item */
 
	Pair reftype = SetupSubsidyDecodeParam(this, false);
src/town_cmd.cpp
Show inline comments
 
@@ -1705,7 +1705,7 @@ CommandCost CmdFoundTown(TileIndex tile,
 
		old_generating_world.Restore();
 

	
 
		if (t != NULL && !StrEmpty(text)) {
 
			t->name = strdup(text);
 
			t->name = stredup(text);
 
			t->UpdateVirtCoord();
 
		}
 

	
 
@@ -1716,7 +1716,7 @@ CommandCost CmdFoundTown(TileIndex tile,
 
			SetDParam(0, _current_company);
 
			GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
 

	
 
			char *cn = strdup(company_name);
 
			char *cn = stredup(company_name);
 
			SetDParamStr(0, cn);
 
			SetDParam(1, t->index);
 

	
 
@@ -2448,7 +2448,7 @@ CommandCost CmdRenameTown(TileIndex tile
 

	
 
	if (flags & DC_EXEC) {
 
		free(t->name);
 
		t->name = reset ? NULL : strdup(text);
 
		t->name = reset ? NULL : stredup(text);
 

	
 
		t->UpdateVirtCoord();
 
		InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
 
@@ -2525,7 +2525,7 @@ CommandCost CmdTownSetText(TileIndex til
 

	
 
	if (flags & DC_EXEC) {
 
		free(t->text);
 
		t->text = StrEmpty(text) ? NULL : strdup(text);
 
		t->text = StrEmpty(text) ? NULL : stredup(text);
 
		InvalidateWindowData(WC_TOWN_VIEW, p1);
 
	}
 

	
 
@@ -2742,7 +2742,7 @@ static CommandCost TownActionRoadRebuild
 
		SetDParam(0, _current_company);
 
		GetString(company_name, STR_COMPANY_NAME, lastof(company_name));
 

	
 
		char *cn = strdup(company_name);
 
		char *cn = stredup(company_name);
 
		SetDParam(0, t->index);
 
		SetDParamStr(1, cn);
 

	
src/vehicle_cmd.cpp
Show inline comments
 
@@ -751,7 +751,7 @@ static void CloneVehicleName(const Vehic
 

	
 
		/* Check the name is unique. */
 
		if (IsUniqueVehicleName(buf)) {
 
			dst->name = strdup(buf);
 
			dst->name = stredup(buf);
 
			break;
 
		}
 
	}
 
@@ -1029,7 +1029,7 @@ CommandCost CmdRenameVehicle(TileIndex t
 

	
 
	if (flags & DC_EXEC) {
 
		free(v->name);
 
		v->name = reset ? NULL : strdup(text);
 
		v->name = reset ? NULL : stredup(text);
 
		InvalidateWindowClassesData(GetWindowClassForVehicleType(v->type), 1);
 
		MarkWholeScreenDirty();
 
	}
src/video/cocoa/cocoa_v.mm
Show inline comments
 
@@ -622,7 +622,7 @@ void cocoaSetApplicationBundleDir()
 
	CFURLRef url = CFBundleCopyResourcesDirectoryURL(CFBundleGetMainBundle());
 
	if (CFURLGetFileSystemRepresentation(url, true, (unsigned char*)tmp, MAXPATHLEN)) {
 
		AppendPathSeparator(tmp, lastof(tmp));
 
		_searchpaths[SP_APPLICATION_BUNDLE_DIR] = strdup(tmp);
 
		_searchpaths[SP_APPLICATION_BUNDLE_DIR] = stredup(tmp);
 
	} else {
 
		_searchpaths[SP_APPLICATION_BUNDLE_DIR] = NULL;
 
	}
src/waypoint_cmd.cpp
Show inline comments
 
@@ -416,7 +416,7 @@ CommandCost CmdRenameWaypoint(TileIndex 
 

	
 
	if (flags & DC_EXEC) {
 
		free(wp->name);
 
		wp->name = reset ? NULL : strdup(text);
 
		wp->name = reset ? NULL : stredup(text);
 

	
 
		wp->UpdateVirtCoord();
 
	}
0 comments (0 inline, 0 general)