AmendHub

Download:

jcs

/

wallops

/

amendments

/

55

irc: Remove malloc notes


jcs made amendment 55 3 months ago
--- irc.c Fri Sep 29 21:11:57 2023 +++ irc.c Fri Aug 30 09:58:26 2024 @@ -68,21 +68,21 @@ irc_connect(struct chatter *chatter, const char *serve if ((err = _TCPInit()) != 0) panic("TCPInit failed (%d)", err); - conn = xmalloczero(sizeof(struct irc_connection), "irc_connection"); + conn = xmalloczero(sizeof(struct irc_connection)); SLIST_APPEND(&irc_connections_list, conn, irc_connection, list); SLIST_INIT(&conn->channels_list); conn->chatter = chatter; conn->state = IRC_STATE_DISCONNECTED; - conn->hostname = xstrdup(server, "server"); + conn->hostname = xstrdup(server); conn->port = port; if (password && password[0]) - conn->password = xstrdup(password, "password"); - conn->nick = xstrdup(nick, "nick"); - conn->ident = xstrdup(ident, "ident"); - conn->realname = xstrdup(realname, "realname"); + conn->password = xstrdup(password); + conn->nick = xstrdup(nick); + conn->ident = xstrdup(ident); + conn->realname = xstrdup(realname); conn->hide_motd = hide_motd; if (channel && channel[0]) - conn->channel_autojoin = xstrdup(channel, "chan"); + conn->channel_autojoin = xstrdup(channel); chatter_printf(conn->chatter, conn, NULL, "$B***$0 Connecting to $B%s:%d$0...", conn->hostname, conn->port); @@ -94,7 +94,7 @@ irc_connect(struct chatter *chatter, const char *serve return conn; } - if ((err = TCPResolveName(conn->hostname, &ip)) != 0) { + if ((err = DNSResolveName(conn->hostname, &ip, NULL)) != 0) { chatter_printf(conn->chatter, conn, NULL, "$B*!* Couldn't resolve host %s (%d)$0", conn->hostname, err); conn->state = IRC_STATE_DEAD; @@ -800,7 +800,7 @@ irc_process_server(struct irc_connection *conn) return true; case 433: { /* Nick in use, try appending a _ */ - char *new_nick = xmalloc(strlen(conn->nick) + 2, "new nick"); + char *new_nick = xmalloc(strlen(conn->nick) + 2); size_t len; chatter_printf(conn->chatter, conn, NULL, @@ -983,7 +983,7 @@ irc_create_channel(struct irc_connection *conn, char * } } - channel = xmalloczero(sizeof(struct irc_channel), "irc_channel"); + channel = xmalloczero(sizeof(struct irc_channel)); SLIST_APPEND(&conn->channels_list, channel, irc_channel, list); channel->connection = conn; strlcpy(channel->name, channame, sizeof(channel->name)); @@ -1211,7 +1211,7 @@ irc_change_user_nick(struct irc_channel *channel, stru if (strcmp(channel->connection->nick, user->nick) == 0) { xfree(&channel->connection->nick); - channel->connection->nick = xstrdup(nick, "nick"); + channel->connection->nick = xstrdup(nick); chatter_update_titlebar(channel->chatter); } } --- irc.h Mon Sep 25 17:25:27 2023 +++ irc.h Fri Aug 30 14:16:22 2024 @@ -33,7 +33,7 @@ enum { struct irc_msg { short code; char cmd[16]; - char source[64]; + char source[80]; char msg[512]; char arg[IRC_MSG_MAX_ARGS][64]; };