SLUDGE: Move createCString() with string tools

This commit is contained in:
Simei Yin 2018-05-30 19:22:46 +02:00
parent 7edac197e4
commit 6004cd319d
4 changed files with 13 additions and 12 deletions

View File

@ -167,4 +167,15 @@ Common::String decodeFilename(const Common::String &nameIn) {
return newName;
}
char *createCString(const Common::String &s) {
uint n = s.size() + 1;
char *res = new char[n];
if (!checkNew(res)) {
fatal("createCString : Unable to copy String");
return NULL;
}
memcpy(res, s.c_str(), n);
return res;
}
} // End of namespace Sludge

View File

@ -31,6 +31,8 @@ void writeString(Common::String s, Common::WriteStream *stream);
Common::String encodeFilename(const Common::String &nameIn);
Common::String decodeFilename(const Common::String &nameIn);
char *createCString(const Common::String &s);
} // End of namespace Sludge
#endif

View File

@ -239,17 +239,6 @@ void compareVariablesInSecond(const Variable &var1, Variable &var2) {
setVariable(var2, SVT_INT, compareVars(var1, var2));
}
char *createCString(const Common::String &s) {
uint n = s.size() + 1;
char *res = new char[n];
if (!checkNew(res)) {
fatal("createCString : Unable to copy String");
return NULL;
}
memcpy(res, s.c_str(), n);
return res;
}
void makeTextVar(Variable &thisVar, const Common::String &txt) {
unlinkVar(thisVar);
thisVar.varType = SVT_STRING;

View File

@ -90,7 +90,6 @@ void newCostumeVariable(Variable &thisVar, struct Persona *i);
void makeTextVar(Variable &thisVar, const Common::String &txt);
void addVariablesInSecond(Variable &var1, Variable &var2);
void compareVariablesInSecond(const Variable &var1, Variable &var2);
char *createCString(const Common::String &s);
// Misc.