summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-04-25 15:40:32 +0000
committerrubidium <rubidium@openttd.org>2014-04-25 15:40:32 +0000
commit9ed12b0f07edb342aaff21c130d325fd158a9d5b (patch)
treef42aa775396b4ebda4d119f76e80a77c180936c7 /src/ai
parent4227f495c51ea909707505ec2ef1c730a382965d (diff)
downloadopenttd-9ed12b0f07edb342aaff21c130d325fd158a9d5b.tar.xz
(svn r26509) -Codechange: replace strdup with stredup (the latter ensures the return is not NULL)
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/ai_config.cpp3
-rw-r--r--src/ai/ai_info.cpp9
-rw-r--r--src/ai/ai_scanner.cpp2
3 files changed, 8 insertions, 6 deletions
diff --git a/src/ai/ai_config.cpp b/src/ai/ai_config.cpp
index 65365f4d4..f920d3101 100644
--- a/src/ai/ai_config.cpp
+++ b/src/ai/ai_config.cpp
@@ -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 *name, int value)
if (it != this->settings.end()) {
(*it).second = value;
} else {
- this->settings[strdup(name)] = value;
+ this->settings[stredup(name)] = value;
}
return;
diff --git a/src/ai/ai_info.cpp b/src/ai/ai_info.cpp
index 9c9f3b47e..e048a5457 100644
--- a/src/ai/ai_info.cpp
+++ b/src/ai/ai_info.cpp
@@ -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<AIInfo, ST_AI>() { return "AIInfo"; }
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<AIInfo, ST_AI>() { return "AIInfo"; }
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<AIInfo, ST_AI>() { return "AIInfo"; }
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);
diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp
index 2d7ab4119..4eb207147 100644
--- a/src/ai/ai_scanner.cpp
+++ b/src/ai/ai_scanner.cpp
@@ -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");
}