(svn r26509) -Codechange: replace strdup with stredup (the latter ensures the return is not NULL)
This commit is contained in:
@@ -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. */
|
||||
|
Reference in New Issue
Block a user