Convert simple uses of alloca/strcpy to LOCAL_COPY.

git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@232 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Tim Cava
2013-02-24 07:32:59 +00:00
parent a7c93a3950
commit d7a0c781f8
13 changed files with 19 additions and 38 deletions

View File

@@ -1198,8 +1198,7 @@ BUILT_IN_COMMAND(kickban)
if (rest && !*rest) if (rest && !*rest)
rest = NULL; rest = NULL;
} }
tspec = alloca(strlen(spec)+1); tspec = LOCAL_COPY(spec);
strcpy(tspec, spec);
while ((tnick = next_in_comma_list(tspec, &tspec))) while ((tnick = next_in_comma_list(tspec, &tspec)))
{ {
int exact = 1; int exact = 1;

View File

@@ -1259,8 +1259,7 @@ static void add_files(char *args, char *rest)
struct dirent *dir; struct dirent *dir;
struct stat statbuf; struct stat statbuf;
path = alloca(strlen(rest)+1); path = LOCAL_COPY(rest);
strcpy(path, rest);
temp = alloca(BIG_BUFFER_SIZE + 1); temp = alloca(BIG_BUFFER_SIZE + 1);
*temp = 0; *temp = 0;

View File

@@ -1049,8 +1049,7 @@ int server = -1;
char *buffer = NULL; char *buffer = NULL;
char *save_buffer = NULL; char *save_buffer = NULL;
int num = 0, count = 0; int num = 0, count = 0;
m_buff = alloca(strlen(match)+1); m_buff = LOCAL_COPY(match);
strcpy(m_buff, match);
bitchsay("Killing all matching %s.", pattern); bitchsay("Killing all matching %s.", pattern);
while ((nick = next_in_comma_list(m_buff, &m_buff))) while ((nick = next_in_comma_list(m_buff, &m_buff)))
{ {

View File

@@ -230,8 +230,7 @@ static int find_cset_variable(CSetArray *array, char *org_name, int *cnt)
char *name = NULL; char *name = NULL;
len = strlen(org_name); len = strlen(org_name);
name = alloca(len + 1); name = LOCAL_COPY(org_name);
strcpy(name, org_name);
upper(name); upper(name);
var_index = 0; var_index = 0;
@@ -708,8 +707,7 @@ static int find_wset_variable(WSetArray *array, char *org_name, int *cnt)
char *name = NULL; char *name = NULL;
len = strlen(org_name); len = strlen(org_name);
name = alloca(len + 1); name = LOCAL_COPY(org_name);
strcpy(name, org_name);
upper(name); upper(name);
var_index = 0; var_index = 0;

View File

@@ -152,8 +152,7 @@ int parse_debug(char *value, int nvalue, char **rv)
if (!value) if (!value)
return 0; return 0;
copy = alloca(strlen(value) + 1); copy = LOCAL_COPY(value);
strcpy(copy, value);
while ((str1 = new_next_arg(copy, &copy))) while ((str1 = new_next_arg(copy, &copy)))
{ {

View File

@@ -467,8 +467,7 @@ ChannelList *chan = NULL;
if (!nick_isop(Nick) || get_cset_int_var(chan->csets, KICK_OPS_CSET)) if (!nick_isop(Nick) || get_cset_int_var(chan->csets, KICK_OPS_CSET))
{ {
char *ban, *u, *h; char *ban, *u, *h;
u = alloca(strlen(Nick->host)+1); u = LOCAL_COPY(Nick->host);
strcpy(u, Nick->host);
h = strchr(u, '@'); h = strchr(u, '@');
*h++ = 0; *h++ = 0;
ban = ban_it(Nick->nick, u, h, Nick->ip); ban = ban_it(Nick->nick, u, h, Nick->ip);

View File

@@ -895,8 +895,7 @@ IrcVariable *fget_var_address(char *var_name)
IrcVariable *var = NULL; IrcVariable *var = NULL;
int cnt, int cnt,
msv_index; msv_index;
char *tmp_var = alloca(strlen(var_name)+1); char *tmp_var = LOCAL_COPY(var_name);
strcpy(tmp_var, var_name);
upper(tmp_var); upper(tmp_var);
if ((var = find_ext_fset_var(tmp_var))) if ((var = find_ext_fset_var(tmp_var)))
return var; return var;

View File

@@ -798,8 +798,7 @@ BUILT_IN_KEYBINDING(input_add_character)
{ {
char *ptr = NULL; char *ptr = NULL;
ptr = alloca(strlen(&(THIS_CHAR)) + 1); ptr = LOCAL_COPY(&(THIS_CHAR));
strcpy(ptr, &(THIS_CHAR));
THIS_CHAR = key; THIS_CHAR = key;
NEXT_CHAR = 0; NEXT_CHAR = 0;
ADD_TO_INPUT(ptr); ADD_TO_INPUT(ptr);

View File

@@ -723,16 +723,14 @@ void numbered_command(char *from, int comm, char **ArgList)
*/ */
if ((p = (char *)strchr(ArgList[2], '@'))) { if ((p = (char *)strchr(ArgList[2], '@'))) {
*p++ = '\0'; *p++ = '\0';
ident = (char *)alloca(strlen(ArgList[2])+1); ident = LOCAL_COPY(ArgList[2]);
strcpy(ident, ArgList[2]);
for(;*p == ' ';) for(;*p == ' ';)
p++; p++;
host = p; host = p;
if ((p = (char *)strchr(p, '\n'))) if ((p = (char *)strchr(p, '\n')))
*p = '\0'; *p = '\0';
p = host; p = host;
host = (char *)alloca(strlen(p)+1); host = LOCAL_COPY(p);
strcpy(host, p);
} }
put_it("%s", convert_output_format(fget_string_var(FORMAT_WHOIS_HEADER_FSET), NULL)); put_it("%s", convert_output_format(fget_string_var(FORMAT_WHOIS_HEADER_FSET), NULL));

View File

@@ -138,8 +138,7 @@ char *p = NULL;
char *pat; char *pat;
if (!str || !*str || !get_int_var(AUTO_RESPONSE_VAR)) if (!str || !*str || !get_int_var(AUTO_RESPONSE_VAR))
return 0; return 0;
p = alloca(strlen(auto_str)+1); p = LOCAL_COPY(auto_str);
strcpy(p, auto_str);
if (p && *p) if (p && *p)
{ {
while ((pat = next_arg(p, &p))) while ((pat = next_arg(p, &p)))
@@ -1090,8 +1089,7 @@ static void p_channel(char *from, char **ArgList)
#ifdef WANT_NSLOOKUP #ifdef WANT_NSLOOKUP
char *host; char *host;
#endif #endif
user = alloca(strlen(FromUserHost)+1); user = LOCAL_COPY(FromUserHost);
strcpy(user, FromUserHost);
#ifdef WANT_NSLOOKUP #ifdef WANT_NSLOOKUP
if ((host = strchr(user, '@'))) if ((host = strchr(user, '@')))

View File

@@ -196,8 +196,7 @@ char *new_path, *p;
int count = 0; int count = 0;
int doit = 0; int doit = 0;
new_path = alloca(strlen(path)+1); new_path = LOCAL_COPY(path);
strcpy(new_path, path);
if ((p = strrchr(new_path, '/'))) if ((p = strrchr(new_path, '/')))
*p = 0; *p = 0;
if (!(dptr = opendir(new_path))) if (!(dptr = opendir(new_path)))
@@ -247,8 +246,7 @@ struct dirent *dir;
struct stat st; struct stat st;
char *ret = NULL, *p; char *ret = NULL, *p;
int count = 0; int count = 0;
new_path = alloca(strlen(path)+1); new_path = LOCAL_COPY(path);
strcpy(new_path, path);
if ((p = strrchr(new_path, '/'))) if ((p = strrchr(new_path, '/')))
*p = 0; *p = 0;
else else
@@ -274,8 +272,7 @@ int count = 0;
if (name) if (name)
{ {
char *pid, *n_tty, *h_name; char *pid, *n_tty, *h_name;
pid = alloca(strlen(p)+1); pid = LOCAL_COPY(p);
strcpy(pid, p);
n_tty = strchr(pid, '.'); *n_tty++ = 0; n_tty = strchr(pid, '.'); *n_tty++ = 0;
h_name = strchr(n_tty, '.'); *h_name++ = 0; h_name = strchr(n_tty, '.'); *h_name++ = 0;
if (strcmp(name, pid)) if (strcmp(name, pid))

View File

@@ -83,8 +83,7 @@ long hvalue;
if (!strchr(uptr->channels, '*')) if (!strchr(uptr->channels, '*'))
{ {
char *channel, *ptr; char *channel, *ptr;
channel = alloca(strlen(uptr->channels)+1); channel = LOCAL_COPY(uptr->channels);
strcpy(channel, uptr->channels);
while ((ptr = next_in_comma_list(channel, &channel))) while ((ptr = next_in_comma_list(channel, &channel)))
{ {
if (!*ptr) if (!*ptr)

View File

@@ -1186,8 +1186,7 @@ char *ban;
ban = m_3dup(nicklist->nick, "!", nicklist->host); ban = m_3dup(nicklist->nick, "!", nicklist->host);
if (nicklist->ip && nicklist->host) if (nicklist->ip && nicklist->host)
{ {
char *user = alloca(strlen(nicklist->host)+1); char *user = LOCAL_COPY(nicklist->host);
strcpy(user, nicklist->host);
if ((u = strchr(user, '@'))) if ((u = strchr(user, '@')))
*u = 0; *u = 0;
ipban = m_opendup(nicklist->nick, "!", user, "@", nicklist->ip, NULL); ipban = m_opendup(nicklist->nick, "!", user, "@", nicklist->ip, NULL);
@@ -1448,8 +1447,7 @@ int check_channel_match(char *tmp, char *channel)
return 0; return 0;
if (*channel == '*' && (strlen(channel)==1)) if (*channel == '*' && (strlen(channel)==1))
return 1; return 1;
q = chan = alloca(strlen(tmp)+1); q = chan = LOCAL_COPY(tmp);
strcpy(chan, tmp);
while ((p = next_in_comma_list(chan, &chan))) while ((p = next_in_comma_list(chan, &chan)))
{ {