so i've been doing some debugging and having a mem debugger that
preloads and tracks allocs means you need locks, but locks can do
nasty things after forks + threads.... esp if threads held locks.
this allows mem debugging with preloads easily and doesn't muck things
up.
char *token;
char pre_command = 1;
int num_tokens = 0;
+ int len;
- if (!(buf = strdup(exe_cmd)))
- return;
+ len = strlen(exe_cmd);
+ buf = alloca(len + 1);
+ strcpy(buf, exe_cmd);
+ buf[len] = 0;
token = strtok(buf, " \t\n\v");
while (token)
num_tokens++;
token = strtok(NULL, " \t\n\v");
}
- IF_FREE(buf);
if ((!token) && (num_tokens))
{
int i = 0;
- if (!(buf = strdup(exe_cmd)))
- return;
+ len = strlen(exe_cmd);
+ buf = alloca(len + 1);
+ strcpy(buf, exe_cmd);
+ buf[len] = 0;
token = strtok(buf, " \t\n\v");
use_sh = 0;
- if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *))))
- {
- IF_FREE(buf);
- return;
- }
+ args = alloca((num_tokens + 1) * sizeof(char *));
for (i = 0; i < num_tokens; i++)
{
if (token)
{ /* We can run this directly. */
if (!args)
{
- IF_FREE(buf);
- IF_FREE(args);
ERR("arg[0] is NULL!");
return;
}
}
save_errno = errno;
- IF_FREE(buf);
- IF_FREE(args);
errno = save_errno;
return;
}