summaryrefslogtreecommitdiff
path: root/src/script/api/script_text.cpp
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/script/api/script_text.cpp
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/script/api/script_text.cpp')
-rw-r--r--src/script/api/script_text.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/script/api/script_text.cpp b/src/script/api/script_text.cpp
index 9fb297990..1529d4577 100644
--- a/src/script/api/script_text.cpp
+++ b/src/script/api/script_text.cpp
@@ -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 parameter, HSQUIRRELVM vm)
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;
}