(svn r26509) -Codechange: replace strdup with stredup (the latter ensures the return is not NULL)
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
void ScriptConfig::Change(const char *name, int version, bool force_exact_match, bool is_random)
|
||||
{
|
||||
free(this->name);
|
||||
this->name = (name == NULL) ? NULL : strdup(name);
|
||||
this->name = (name == NULL) ? NULL : stredup(name);
|
||||
this->info = (name == NULL) ? NULL : this->FindInfo(this->name, version, force_exact_match);
|
||||
this->version = (info == NULL) ? -1 : info->GetVersion();
|
||||
this->is_random = is_random;
|
||||
@@ -45,14 +45,14 @@ void ScriptConfig::Change(const char *name, int version, bool force_exact_match,
|
||||
|
||||
ScriptConfig::ScriptConfig(const ScriptConfig *config)
|
||||
{
|
||||
this->name = (config->name == NULL) ? NULL : strdup(config->name);
|
||||
this->name = (config->name == NULL) ? NULL : stredup(config->name);
|
||||
this->info = config->info;
|
||||
this->version = config->version;
|
||||
this->config_list = NULL;
|
||||
this->is_random = config->is_random;
|
||||
|
||||
for (SettingValueList::const_iterator it = config->settings.begin(); it != config->settings.end(); it++) {
|
||||
this->settings[strdup((*it).first)] = (*it).second;
|
||||
this->settings[stredup((*it).first)] = (*it).second;
|
||||
}
|
||||
this->AddRandomDeviation();
|
||||
}
|
||||
@@ -117,7 +117,7 @@ void ScriptConfig::SetSetting(const char *name, int value)
|
||||
if (it != this->settings.end()) {
|
||||
(*it).second = value;
|
||||
} else {
|
||||
this->settings[strdup(name)] = value;
|
||||
this->settings[stredup(name)] = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ int ScriptConfig::GetVersion() const
|
||||
|
||||
void ScriptConfig::StringToSettings(const char *value)
|
||||
{
|
||||
char *value_copy = strdup(value);
|
||||
char *value_copy = stredup(value);
|
||||
char *s = value_copy;
|
||||
|
||||
while (s != NULL) {
|
||||
|
Reference in New Issue
Block a user