refactor code to make better use of std::string and simplify using changes to Variable class API

This commit is contained in:
Axel Kohlmeyer
2020-07-17 01:23:17 -04:00
parent 63bebf58fd
commit 2fb6a61f2a
6 changed files with 41 additions and 64 deletions

View File

@ -578,13 +578,14 @@ void Variable::set(char *name, int narg, char **arg)
called via library interface, so external programs can set variables
------------------------------------------------------------------------- */
int Variable::set_string(char *name, char *str)
int Variable::set_string(const char *name, const char *str)
{
int ivar = find(name);
if (ivar < 0) return -1;
if (style[ivar] != STRING) return -1;
delete [] data[ivar][0];
copy(1,&str,data[ivar]);
data[ivar][0] = new char[strlen(str)+1];
strcpy(data[ivar][0],str);
return 0;
}