Convert uses of new_malloc/strcpy in take_acro() to m_strdup. While

I'm here, don't cast what new_malloc returns.


git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@257 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Tim Cava
2013-07-07 09:17:02 +00:00
parent 5ab9f87936
commit e42c16a832

View File

@@ -237,13 +237,10 @@ prec *take_acro(grec *acro, prec *players, char *nick, char *host, char *stuff)
prec *tmp, *last = NULL;
if (!players)
{
players = (prec *)new_malloc(sizeof(prec));
players->nick = (char *)new_malloc(strlen(nick)+1);
players->host = (char *)new_malloc(strlen(host)+1);
players->acro = (char *)new_malloc(strlen(stuff)+1);
strcpy(players->nick, nick);
strcpy(players->host, host);
strcpy(players->acro, stuff);
players = new_malloc(sizeof(prec));
players->nick = m_strdup(nick);
players->host = m_strdup(host);
players->acro = m_strdup(stuff);
send_to_server("PRIVMSG %s :Answer set to \"%s\"\r\nPRIVMSG %s :You are player #%d", nick, stuff, nick, ++acro->players);
return players;
}
@@ -265,8 +262,7 @@ prec *take_acro(grec *acro, prec *players, char *nick, char *host, char *stuff)
return players;
}
else {
tmp->last = (char *)new_malloc(strlen(stuff)+1);
strcpy(tmp->last, stuff);
tmp->last = m_strdup(stuff);
send_to_server("PRIVMSG %s :You already submitted an answer, submit once more to change.", nick);
return players;
}
@@ -275,13 +271,10 @@ prec *take_acro(grec *acro, prec *players, char *nick, char *host, char *stuff)
}
if (acro->players < MAXPLAYERS && last)
{
tmp = last->next = (prec *)new_malloc(sizeof(prec));
tmp->nick = (char *)new_malloc(strlen(nick)+1);
tmp->host = (char *)new_malloc(strlen(host)+1);
tmp->acro = (char *)new_malloc(strlen(stuff)+1);
strcpy(tmp->nick, nick);
strcpy(tmp->host, host);
strcpy(tmp->acro, stuff);
tmp = last->next = new_malloc(sizeof(prec));
tmp->nick = m_strdup(nick);
tmp->host = m_strdup(host);
tmp->acro = m_strdup(stuff);
send_to_server("PRIVMSG %s :Answer set to \"%s\"\r\nPRIVMSG %s :You are player #%d", nick, stuff, nick, ++acro->players);
}
else