{
/* Remove this option from the argv array. */
for (arg = i; arg < argc; arg ++)
- argv[arg] = argv[arg + 1];
+ {
+ free (argv[arg]);
+ argv[arg] = argv[arg + 1];
+ }
argc --;
i --;
trace_funcs = 1;
{
/* Remove this option from the argv array. */
for (arg = i; arg < argc; arg ++)
- argv[arg] = argv[arg + 1];
+ {
+ free (argv[arg]);
+ argv[arg] = argv[arg + 1];
+ }
argc --;
i --;
disas = 1;
{
/* Remove this option from the argv array. */
for (arg = i; arg < argc; arg ++)
- argv[arg] = argv[arg + 1];
+ {
+ free (argv[arg]);
+ argv[arg] = argv[arg + 1];
+ }
argc --;
ptr = argv[i];
/* Remove this option from the argv array. */
for (arg = i; arg < argc; arg ++)
- argv[arg] = argv[arg + 1];
+ {
+ free (argv[arg]);
+ argv[arg] = argv[arg + 1];
+ }
argc --;
i --;
}
char * const *argv)
{
int i;
+ char **argv_copy;
SIM_DESC sd = sim_state_alloc (kind, cb);
SIM_ASSERT (STATE_MAGIC (sd) == SIM_MAGIC_NUMBER);
sim_callback = cb;
- sim_target_parse_arg_array (argv);
+ /* Copy over the argv contents so we can modify them. */
+ argv_copy = dupargv (argv);
- if (argv[1] != NULL)
+ sim_target_parse_arg_array (argv_copy);
+
+ if (argv_copy[1] != NULL)
{
int i;
/* Scan for memory-size switches. */
- for (i = 0; (argv[i] != NULL) && (argv[i][0] != 0); i++)
- if (argv[i][0] == '-' && argv[i][1] == 'm')
+ for (i = 0; (argv_copy[i] != NULL) && (argv_copy[i][0] != 0); i++)
+ if (argv_copy[i][0] == '-' && argv_copy[i][1] == 'm')
{
- if (argv[i][2] != '\0')
- mem_size = atoi (&argv[i][2]);
- else if (argv[i + 1] != NULL)
+ if (argv_copy[i][2] != '\0')
+ mem_size = atoi (&argv_copy[i][2]);
+ else if (argv_copy[i + 1] != NULL)
{
- mem_size = atoi (argv[i + 1]);
+ mem_size = atoi (argv_copy[i + 1]);
i++;
}
else
}
}
+ freeargv (argv_copy);
+
return sd;
}