diff options
author | rubidium <rubidium@openttd.org> | 2014-04-25 15:40:32 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2014-04-25 15:40:32 +0000 |
commit | 9ed12b0f07edb342aaff21c130d325fd158a9d5b (patch) | |
tree | f42aa775396b4ebda4d119f76e80a77c180936c7 /src/strgen | |
parent | 4227f495c51ea909707505ec2ef1c730a382965d (diff) | |
download | openttd-9ed12b0f07edb342aaff21c130d325fd158a9d5b.tar.xz |
(svn r26509) -Codechange: replace strdup with stredup (the latter ensures the return is not NULL)
Diffstat (limited to 'src/strgen')
-rw-r--r-- | src/strgen/strgen.cpp | 4 | ||||
-rw-r--r-- | src/strgen/strgen_base.cpp | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index 4cd2454f4..7769ca242 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -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, FileWriter { * @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"); diff --git a/src/strgen/strgen_base.cpp b/src/strgen/strgen_base.cpp index 27c76631c..ef30a4c8a 100644 --- a/src/strgen/strgen_base.cpp +++ b/src/strgen/strgen_base.cpp @@ -40,7 +40,7 @@ static const CmdStruct *ParseCommandString(const char **str, char *param, int *a * @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 *ParseCommandString(const char **str, char *param, int *a * @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(ParsedCommandStruct *p, const char *s, bool war } 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 *str) 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. */ |