summaryrefslogtreecommitdiff
path: root/src/3rdparty/squirrel
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2014-09-16 21:13:24 +0000
committerrubidium <rubidium@openttd.org>2014-09-16 21:13:24 +0000
commita1d4148be565124e4e48251b78d91e7174d0f825 (patch)
tree2a4fc9140e15d605cfc34121a776f4177b1dccb3 /src/3rdparty/squirrel
parent168511816989ed8ea6de4721601f008d719298e9 (diff)
downloadopenttd-a1d4148be565124e4e48251b78d91e7174d0f825.tar.xz
(svn r26841) -Codechange [Squirrel]: move the actual initialisation of instance variables of SQString into the constructor
Diffstat (limited to 'src/3rdparty/squirrel')
-rw-r--r--src/3rdparty/squirrel/squirrel/sqstate.cpp15
-rw-r--r--src/3rdparty/squirrel/squirrel/sqstring.h2
2 files changed, 11 insertions, 6 deletions
diff --git a/src/3rdparty/squirrel/squirrel/sqstate.cpp b/src/3rdparty/squirrel/squirrel/sqstate.cpp
index 73ee649d5..b7c63746f 100644
--- a/src/3rdparty/squirrel/squirrel/sqstate.cpp
+++ b/src/3rdparty/squirrel/squirrel/sqstate.cpp
@@ -523,11 +523,7 @@ SQString *SQStringTable::Add(const SQChar *news,SQInteger len)
}
SQString *t=(SQString *)SQ_MALLOC(len+sizeof(SQString));
- new (t) SQString;
- memcpy(t->_val,news,(size_t)len);
- t->_val[len] = '\0';
- t->_len = len;
- t->_hash = ::_hashstr(news,(size_t)len);
+ new (t) SQString(news, len);
t->_next = _strings[h];
_strings[h] = t;
_slotused++;
@@ -536,6 +532,15 @@ SQString *SQStringTable::Add(const SQChar *news,SQInteger len)
return t;
}
+SQString::SQString(const SQChar *news, SQInteger len)
+{
+ memcpy(_val,news,(size_t)len);
+ _val[len] = '\0';
+ _len = len;
+ _hash = ::_hashstr(news,(size_t)len);
+ _next = NULL;
+}
+
void SQStringTable::Resize(SQInteger size)
{
SQInteger oldsize=_numofslots;
diff --git a/src/3rdparty/squirrel/squirrel/sqstring.h b/src/3rdparty/squirrel/squirrel/sqstring.h
index 14f09e1b0..a5f298e1e 100644
--- a/src/3rdparty/squirrel/squirrel/sqstring.h
+++ b/src/3rdparty/squirrel/squirrel/sqstring.h
@@ -13,7 +13,7 @@ inline SQHash _hashstr (const SQChar *s, size_t l)
struct SQString : public SQRefCounted
{
- SQString(){}
+ SQString(const SQChar *news, SQInteger len);
~SQString(){}
public:
static SQString *Create(SQSharedState *ss, const SQChar *, SQInteger len = -1 );