diff options
author | TingPing <tingping@tingping.se> | 2014-12-28 06:37:25 -0500 |
---|---|---|
committer | TingPing <tingping@tingping.se> | 2014-12-28 06:44:44 -0500 |
commit | 83032b1aa3c3e5910c5cfd3e0ea1d25827f56475 (patch) | |
tree | 9be32a04d3070eac82177e11d182dad40a63baa7 /src/common/inbound.c | |
parent | c4cb1b25ec06a5b0cb718c6f8e74630df9a9bc64 (diff) |
Use glib for all allocations
- Removes need to check for malloc failure - Removes need for NULL checks on free - Adds checks for integer overflows - Removes some extra memset calls - Removes chance of mixing libc and glib malloc/free
Diffstat (limited to 'src/common/inbound.c')
-rw-r--r-- | src/common/inbound.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/common/inbound.c b/src/common/inbound.c index dbb29b57..a3b1b7da 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -62,7 +62,7 @@ clear_channel (session *sess) if (sess->current_modes) { - free (sess->current_modes); + g_free (sess->current_modes); sess->current_modes = NULL; } @@ -81,9 +81,8 @@ clear_channel (session *sess) void set_topic (session *sess, char *topic, char *stripped_topic) { - if (sess->topic) - free (sess->topic); - sess->topic = strdup (stripped_topic); + g_free (sess->topic); + sess->topic = g_strdup (stripped_topic); fe_set_topic (sess, topic, stripped_topic); } @@ -968,14 +967,14 @@ inbound_notice (server *serv, char *to, char *nick, char *msg, char *ip, int id, /* guess where chanserv meant to post this -sigh- */ if (!g_ascii_strcasecmp (nick, "ChanServ") && !find_dialog (serv, nick)) { - char *dest = strdup (msg + 1); + char *dest = g_strdup (msg + 1); char *end = strchr (dest, ']'); if (end) { *end = 0; sess = find_channel (serv, dest); } - free (dest); + g_free (dest); } } if (!sess) @@ -1454,8 +1453,7 @@ inbound_user_info (session *sess, char *chan, char *user, char *host, if (user && host) { - uhost = g_malloc (strlen (user) + strlen (host) + 2); - sprintf (uhost, "%s@%s", user, host); + uhost = g_strdup_printf ("%s@%s", user, host); } if (chan) |