# HG changeset patch # User Rob Flynn # Date 972349830 0 # Node ID 90e8714bf95b879471e92e569ade466c43801f4b # Parent e1e36f95af9ace29d196e32e039fa5298638c649 [gaim-migrate @ 1031] Fixed a few little memory leaks. committer: Tailor Script diff -r e1e36f95af9a -r 90e8714bf95b plugins/irc.c --- a/plugins/irc.c Mon Oct 23 21:01:25 2000 +0000 +++ b/plugins/irc.c Tue Oct 24 01:10:30 2000 +0000 @@ -47,7 +47,7 @@ #include "pixmaps/ok.xpm" /* FIXME: We shouldn't have hard coded servers and ports :-) */ -#define IRC_SERVER "irc.undernet.org" +#define IRC_SERVER "irc.mozilla.org" #define IRC_PORT 6667 #define IRC_BUF_LEN 4096 @@ -192,7 +192,7 @@ void irc_chat_send( struct gaim_connection *gc, int id, char *message) { struct irc_data *idata = (struct irc_data *)gc->proto_data; - struct irc_channel *channel = g_new0(struct irc_channel, 1); + struct irc_channel *channel = NULL; gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN + 1); /* First lets get our current channel */ @@ -201,6 +201,7 @@ if (!channel) { /* If for some reason we've lost our channel, let's bolt */ + g_free(buf); return; } @@ -365,6 +366,9 @@ add_chat_buddy(convo, buf2[i]); } } + + /* And free our pointers */ + g_strfreev (buf2); return; @@ -432,7 +436,7 @@ gchar u_channel[128]; gchar u_nick[128]; - struct irc_channel *channel = g_new0(struct irc_channel, 1); + struct irc_channel *channel; int id; int j; GList *test = NULL; @@ -472,7 +476,6 @@ serv_got_chat_left(gc, channel->id); idata->channels = g_list_remove(idata->channels, channel); - g_free(channel); } else { struct conversation *convo = NULL; @@ -614,12 +617,26 @@ void irc_close(struct gaim_connection *gc) { struct irc_data *idata = (struct irc_data *)gc->proto_data; + GList *chats = idata->channels; + struct irc_channel *cc; + gchar *buf = (gchar *)g_malloc(IRC_BUF_LEN); - g_snprintf(buf, IRC_BUF_LEN, "QUIT :GAIM [www.marko.net/gaim]\n"); + g_snprintf(buf, IRC_BUF_LEN, "QUIT :Download GAIM [www.marko.net/gaim]\n"); write(idata->fd, buf, strlen(buf)); g_free(buf); + + while (chats) { + cc = (struct irc_channel *)chats->data; + g_free(cc->name); + chats = g_list_remove(chats, cc); + g_free(cc); + } + + if (gc->inpa) + gdk_input_remove(gc->inpa); + close(idata->fd); g_free(gc->proto_data); }