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