Convert uses of new_malloc/strcpy in take_vote() 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@258 13b04d17-f746-0410-82c6-800466cd88b0
This commit is contained in:
Tim Cava
2013-07-07 09:22:04 +00:00
parent e42c16a832
commit c76c962feb

View File

@@ -300,12 +300,10 @@ vrec *take_vote(grec *acro, vrec *voters, prec *players, char *nick, char *host,
} }
if (!voters) if (!voters)
{ {
voters = (vrec *)new_malloc(sizeof(vrec)); voters = new_malloc(sizeof(vrec));
voters->nick = (char *)new_malloc(strlen(nick)+1); voters->nick = m_strdup(nick);
voters->host = (char *)new_malloc(strlen(host)+1); voters->host = m_strdup(host);
voters->vote = atoi(num)-1; voters->vote = atoi(num)-1;
strcpy(voters->nick, nick);
strcpy(voters->host, host);
send_to_server("PRIVMSG %s :Vote recorded...", nick); send_to_server("PRIVMSG %s :Vote recorded...", nick);
return voters; return voters;
} }
@@ -320,12 +318,10 @@ vrec *take_vote(grec *acro, vrec *voters, prec *players, char *nick, char *host,
} }
if (last && !last->next) if (last && !last->next)
{ {
last = last->next = (vrec *)new_malloc(sizeof(vrec)); last = last->next = new_malloc(sizeof(vrec));
last->nick = (char *)new_malloc(strlen(nick)+1+sizeof(char *)); last->nick = m_strdup(nick);
last->host = (char *)new_malloc(strlen(host)+1+sizeof(char *)); last->host = m_strdup(host);
last->vote = atoi(num)-1; last->vote = atoi(num)-1;
strcpy(last->nick, nick);
strcpy(last->host, host);
send_to_server("PRIVMSG %s :Vote recorded...", nick); send_to_server("PRIVMSG %s :Vote recorded...", nick);
} }
return voters; return voters;