changeset 17235:1927f4ead3ca

Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 22 May 2007 18:56:09 +0000
parents 12d0ad970a15
children 94fe470d4c9a
files libpurple/protocols/oscar/bstream.c libpurple/protocols/oscar/family_admin.c libpurple/protocols/oscar/family_alert.c libpurple/protocols/oscar/family_auth.c libpurple/protocols/oscar/family_bart.c libpurple/protocols/oscar/family_bos.c libpurple/protocols/oscar/family_buddy.c libpurple/protocols/oscar/family_chat.c libpurple/protocols/oscar/family_chatnav.c libpurple/protocols/oscar/family_feedbag.c libpurple/protocols/oscar/family_icbm.c libpurple/protocols/oscar/family_icq.c libpurple/protocols/oscar/family_locate.c libpurple/protocols/oscar/family_odir.c libpurple/protocols/oscar/family_oservice.c libpurple/protocols/oscar/family_popup.c libpurple/protocols/oscar/family_userlookup.c libpurple/protocols/oscar/flap_connection.c libpurple/protocols/oscar/misc.c libpurple/protocols/oscar/msgcookie.c libpurple/protocols/oscar/oft.c libpurple/protocols/oscar/rxhandlers.c libpurple/protocols/oscar/snac.c libpurple/protocols/oscar/tlv.c libpurple/protocols/oscar/util.c
diffstat 25 files changed, 309 insertions(+), 309 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/bstream.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/bstream.c	Tue May 22 18:56:09 2007 +0000
@@ -172,10 +172,10 @@
 {
 	guint8 *ob;
 
-	ob = malloc(len);
+	ob = g_malloc(len);
 
 	if (byte_stream_getrawbuf(bs, ob, len) < len) {
-		free(ob);
+		g_free(ob);
 		return NULL;
 	}
 
@@ -186,10 +186,10 @@
 {
 	char *ob;
 
-	ob = malloc(len + 1);
+	ob = g_malloc(len + 1);
 
 	if (byte_stream_getrawbuf(bs, (guint8 *)ob, len) < len) {
-		free(ob);
+		g_free(ob);
 		return NULL;
 	}
 
--- a/libpurple/protocols/oscar/family_admin.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_admin.c	Tue May 22 18:56:09 2007 +0000
@@ -81,12 +81,12 @@
 
 		switch (type) {
 			case 0x0001: {
-				free(sn);
+				g_free(sn);
 				sn = byte_stream_getstr(bs, length);
 			} break;
 
 			case 0x0004: {
-				free(url);
+				g_free(url);
 				url = byte_stream_getstr(bs, length);
 			} break;
 
@@ -95,7 +95,7 @@
 			} break;
 
 			case 0x0011: {
-				free(email);
+				g_free(email);
 				if (length == 0)
 					email = g_strdup("*suppressed");
 				else
@@ -109,9 +109,9 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		userfunc(od, conn, frame, (snac->subtype == 0x0005) ? 1 : 0, perms, err, url, sn, email);
 
-	free(sn);
-	free(url);
-	free(email);
+	g_free(sn);
+	g_free(url);
+	g_free(email);
 
 	return 1;
 }
--- a/libpurple/protocols/oscar/family_alert.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_alert.c	Tue May 22 18:56:09 2007 +0000
@@ -111,10 +111,10 @@
 	for (new = od->emailinfo; (new && memcmp(cookie16, new->cookie16, 16)); new = new->next);
 	if (new) {
 		/* Free some of the old info, if it exists */
-		free(new->cookie8);
-		free(new->cookie16);
-		free(new->url);
-		free(new->domain);
+		g_free(new->cookie8);
+		g_free(new->cookie16);
+		g_free(new->url);
+		g_free(new->domain);
 	} else {
 		/* We don't already have info, so create a new struct for it */
 		new = g_new0(struct aim_emailinfo, 1);
@@ -154,8 +154,8 @@
 
 	aim_tlvlist_free(&tlvlist);
 
-	free(alertitle);
-	free(alerturl);
+	g_free(alertitle);
+	g_free(alerturl);
 
 	return ret;
 }
@@ -210,11 +210,11 @@
 	{
 		struct aim_emailinfo *tmp = od->emailinfo;
 		od->emailinfo = od->emailinfo->next;
-		free(tmp->cookie16);
-		free(tmp->cookie8);
-		free(tmp->url);
-		free(tmp->domain);
-		free(tmp);
+		g_free(tmp->cookie16);
+		g_free(tmp->cookie8);
+		g_free(tmp->url);
+		g_free(tmp->domain);
+		g_free(tmp);
 	}
 
 	return;
--- a/libpurple/protocols/oscar/family_auth.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_auth.c	Tue May 22 18:56:09 2007 +0000
@@ -134,7 +134,7 @@
 	guint8 *password_encoded;
 
 	passwdlen = strlen(password);
-	password_encoded = (guint8 *)malloc(passwdlen+1);
+	password_encoded = (guint8 *)g_malloc(passwdlen+1);
 	if (passwdlen > MAXICQPASSLEN)
 		passwdlen = MAXICQPASSLEN;
 
@@ -159,7 +159,7 @@
 
 	aim_tlvlist_write(&frame->data, &tl);
 
-	free(password_encoded);
+	g_free(password_encoded);
 	aim_tlvlist_free(&tl);
 
 	flap_connection_send(conn, frame);
@@ -531,7 +531,7 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, keystr);
 
-	free(keystr);
+	g_free(keystr);
 
 	return ret;
 }
@@ -589,18 +589,18 @@
 {
 	if (od->authinfo != NULL)
 	{
-		free(od->authinfo->sn);
-		free(od->authinfo->bosip);
-		free(od->authinfo->errorurl);
-		free(od->authinfo->email);
-		free(od->authinfo->chpassurl);
-		free(od->authinfo->latestrelease.name);
-		free(od->authinfo->latestrelease.url);
-		free(od->authinfo->latestrelease.info);
-		free(od->authinfo->latestbeta.name);
-		free(od->authinfo->latestbeta.url);
-		free(od->authinfo->latestbeta.info);
-		free(od->authinfo);
+		g_free(od->authinfo->sn);
+		g_free(od->authinfo->bosip);
+		g_free(od->authinfo->errorurl);
+		g_free(od->authinfo->email);
+		g_free(od->authinfo->chpassurl);
+		g_free(od->authinfo->latestrelease.name);
+		g_free(od->authinfo->latestrelease.url);
+		g_free(od->authinfo->latestrelease.info);
+		g_free(od->authinfo->latestbeta.name);
+		g_free(od->authinfo->latestbeta.url);
+		g_free(od->authinfo->latestbeta.info);
+		g_free(od->authinfo);
 	}
 }
 
--- a/libpurple/protocols/oscar/family_bart.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_bart.c	Tue May 22 18:56:09 2007 +0000
@@ -151,9 +151,9 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, sn, iconcsumtype, iconcsum, iconcsumlen, icon, iconlen);
 
-	free(sn);
-	free(iconcsum);
-	free(icon);
+	g_free(sn);
+	g_free(iconcsum);
+	g_free(icon);
 
 	return ret;
 }
--- a/libpurple/protocols/oscar/family_bos.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_bos.c	Tue May 22 18:56:09 2007 +0000
@@ -136,7 +136,7 @@
 	else
 		return -EINVAL;
 
-	localcpy = strdup(denylist);
+	localcpy = g_strdup(denylist);
 
 	listcount = aimutil_itemcnt(localcpy, '&');
 	packlen = aimutil_tokslen(localcpy, 99, '&') + listcount + 9;
@@ -152,9 +152,9 @@
 		byte_stream_put8(&frame->data, strlen(tmpptr));
 		byte_stream_putstr(&frame->data, tmpptr);
 
-		free(tmpptr);
+		g_free(tmpptr);
 	}
-	free(localcpy);
+	g_free(localcpy);
 
 	flap_connection_send(conn, frame);
 
--- a/libpurple/protocols/oscar/family_buddy.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_buddy.c	Tue May 22 18:56:09 2007 +0000
@@ -135,7 +135,7 @@
 	char *localcpy = NULL;
 	char *tmpptr = NULL;
 
-	if (!buddy_list || !(localcpy = strdup(buddy_list)))
+	if (!buddy_list || !(localcpy = g_strdup(buddy_list)))
 		return -EINVAL;
 
 	for (tmpptr = strtok(localcpy, "&"); tmpptr; ) {
@@ -162,7 +162,7 @@
 
 	flap_connection_send(conn, frame);
 
-	free(localcpy);
+	g_free(localcpy);
 
 	return 0;
 }
--- a/libpurple/protocols/oscar/family_chat.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_chat.c	Tue May 22 18:56:09 2007 +0000
@@ -41,8 +41,8 @@
 	struct chatconnpriv *ccp = (struct chatconnpriv *)conn->internal;
 
 	if (ccp)
-		free(ccp->name);
-	free(ccp);
+		g_free(ccp->name);
+	g_free(ccp);
 
 	return;
 }
@@ -100,12 +100,12 @@
 		return -EINVAL;
 
 	if (conn->internal)
-		free(conn->internal);
+		g_free(conn->internal);
 
 	ccp = g_new(struct chatconnpriv, 1);
 
 	ccp->exchange = exchange;
-	ccp->name = strdup(roomname);
+	ccp->name = g_strdup(roomname);
 	ccp->instance = instance;
 
 	conn->internal = (void *)ccp;
@@ -203,7 +203,7 @@
 		ByteStream occbs;
 
 		/* Allocate enough userinfo structs for all occupants */
-		userinfo = calloc(usercount, sizeof(aim_userinfo_t));
+		userinfo = g_new0(aim_userinfo_t, usercount);
 
 		byte_stream_init(&occbs, tlv->value, tlv->length);
 
@@ -301,14 +301,14 @@
 				maxvisiblemsglen);
 	}
 
-	free(roominfo.name);
+	g_free(roominfo.name);
 
 	while (usercount > 0)
 		aim_info_free(&userinfo[--usercount]);
 
-	free(userinfo);
-	free(roomname);
-	free(roomdesc);
+	g_free(userinfo);
+	g_free(roomname);
+	g_free(roomdesc);
 	aim_tlvlist_free(&tlvlist);
 
 	return ret;
@@ -324,7 +324,7 @@
 
 	while (byte_stream_empty(bs)) {
 		curcount++;
-		userinfo = realloc(userinfo, curcount * sizeof(aim_userinfo_t));
+		userinfo = g_realloc(userinfo, curcount * sizeof(aim_userinfo_t));
 		aim_info_extract(od, bs, &userinfo[curcount-1]);
 	}
 
@@ -332,7 +332,7 @@
 		ret = userfunc(od, conn, frame, curcount, userinfo);
 
 	aim_info_free(userinfo);
-	free(userinfo);
+	g_free(userinfo);
 
 	return ret;
 }
@@ -488,8 +488,8 @@
 		cookie[i] = byte_stream_get8(bs);
 
 	if ((ck = aim_uncachecookie(od, cookie, AIM_COOKIETYPE_CHAT))) {
-		free(ck->data);
-		free(ck);
+		g_free(ck->data);
+		g_free(ck);
 	}
 
 	/*
@@ -569,9 +569,9 @@
 		ret = userfunc(od, conn, frame, &userinfo, len, msg, encoding, language);
 
 	aim_info_free(&userinfo);
-	free(msg);
-	free(encoding);
-	free(language);
+	g_free(msg);
+	g_free(encoding);
+	g_free(language);
 	aim_tlvlist_free(&tlvlist);
 
 	return ret;
--- a/libpurple/protocols/oscar/family_chatnav.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_chatnav.c	Tue May 22 18:56:09 2007 +0000
@@ -133,7 +133,7 @@
 
 		curexchange++;
 
-		exchanges = realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo));
+		exchanges = g_realloc(exchanges, curexchange * sizeof(struct aim_chat_exchangeinfo));
 
 		/* exchange number */
 		exchanges[curexchange-1].number = byte_stream_get16(&tbs);
@@ -300,13 +300,13 @@
 		ret = userfunc(od, conn, frame, snac2->type, maxrooms, curexchange, exchanges);
 
 	for (curexchange--; curexchange >= 0; curexchange--) {
-		free(exchanges[curexchange].name);
-		free(exchanges[curexchange].charset1);
-		free(exchanges[curexchange].lang1);
-		free(exchanges[curexchange].charset2);
-		free(exchanges[curexchange].lang2);
+		g_free(exchanges[curexchange].name);
+		g_free(exchanges[curexchange].charset1);
+		g_free(exchanges[curexchange].lang1);
+		g_free(exchanges[curexchange].charset2);
+		g_free(exchanges[curexchange].lang2);
 	}
-	free(exchanges);
+	g_free(exchanges);
 	aim_tlvlist_free(&tlvlist);
 
 	return ret;
@@ -345,7 +345,7 @@
 	if (detaillevel != 0x02) {
 		purple_debug_misc("oscar", "unknown detaillevel in create room response (0x%02x)\n", detaillevel);
 		aim_tlvlist_free(&tlvlist);
-		free(ck);
+		g_free(ck);
 		return 0;
 	}
 
@@ -378,9 +378,9 @@
 		ret = userfunc(od, conn, frame, snac2->type, fqcn, instance, exchange, flags, createtime, maxmsglen, maxoccupancy, createperms, unknown, name, ck);
 	}
 
-	free(ck);
-	free(name);
-	free(fqcn);
+	g_free(ck);
+	g_free(name);
+	g_free(fqcn);
 	aim_tlvlist_free(&innerlist);
 	aim_tlvlist_free(&tlvlist);
 
@@ -442,8 +442,8 @@
 		purple_debug_misc("oscar", "chatnav_parse_info: unknown request subtype (%04x)\n", snac2->type);
 
 	if (snac2)
-		free(snac2->data);
-	free(snac2);
+		g_free(snac2->data);
+	g_free(snac2);
 
 	return ret;
 }
--- a/libpurple/protocols/oscar/family_feedbag.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_feedbag.c	Tue May 22 18:56:09 2007 +0000
@@ -81,7 +81,7 @@
 	if (newlen > 0) {
 		guint8 *newdata;
 
-		newdata = (guint8 *)malloc((newlen)*sizeof(guint8));
+		newdata = (guint8 *)g_malloc((newlen)*sizeof(guint8));
 		newlen = 0;
 		if (group->gid == 0x0000) {
 			for (cur=list; cur; cur=cur->next)
@@ -94,7 +94,7 @@
 		}
 		aim_tlvlist_replace_raw(&group->data, 0x00c8, newlen, newdata);
 
-		free(newdata);
+		g_free(newdata);
 	}
 }
 
@@ -115,11 +115,11 @@
 	gboolean exists;
 	struct aim_ssi_item *cur, *new;
 
-	new = (struct aim_ssi_item *)malloc(sizeof(struct aim_ssi_item));
+	new = (struct aim_ssi_item *)g_malloc(sizeof(struct aim_ssi_item));
 
 	/* Set the name */
 	if (name) {
-		new->name = (char *)malloc((strlen(name)+1)*sizeof(char));
+		new->name = (char *)g_malloc((strlen(name)+1)*sizeof(char));
 		strcpy(new->name, name);
 	} else
 		new->name = NULL;
@@ -213,9 +213,9 @@
 	}
 
 	/* Free the removed item */
-	free(del->name);
+	g_free(del->name);
 	aim_tlvlist_free(&del->data);
-	free(del);
+	g_free(del);
 
 	return 0;
 }
@@ -510,7 +510,7 @@
 		for (cur1=od->ssi.local; cur1 && (n < 15); cur1=cur1->next) {
 			if (!aim_ssi_itemlist_find(od->ssi.official, cur1->gid, cur1->bid)) {
 				n++;
-				new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
+				new = (struct aim_ssi_tmp *)g_malloc(sizeof(struct aim_ssi_tmp));
 				new->action = SNAC_SUBTYPE_FEEDBAG_ADD;
 				new->ack = 0xffff;
 				new->name = NULL;
@@ -530,7 +530,7 @@
 		for (cur1=od->ssi.official; cur1 && (n < 15); cur1=cur1->next) {
 			if (!aim_ssi_itemlist_find(od->ssi.local, cur1->gid, cur1->bid)) {
 				n++;
-				new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
+				new = (struct aim_ssi_tmp *)g_malloc(sizeof(struct aim_ssi_tmp));
 				new->action = SNAC_SUBTYPE_FEEDBAG_DEL;
 				new->ack = 0xffff;
 				new->name = NULL;
@@ -551,7 +551,7 @@
 			cur2 = aim_ssi_itemlist_find(od->ssi.official, cur1->gid, cur1->bid);
 			if (cur2 && (aim_ssi_itemlist_cmp(cur1, cur2))) {
 				n++;
-				new = (struct aim_ssi_tmp *)malloc(sizeof(struct aim_ssi_tmp));
+				new = (struct aim_ssi_tmp *)g_malloc(sizeof(struct aim_ssi_tmp));
 				new->action = SNAC_SUBTYPE_FEEDBAG_MOD;
 				new->ack = 0xffff;
 				new->name = NULL;
@@ -609,25 +609,25 @@
 	while (cur) {
 		del = cur;
 		cur = cur->next;
-		free(del->name);
+		g_free(del->name);
 		aim_tlvlist_free(&del->data);
-		free(del);
+		g_free(del);
 	}
 
 	cur = od->ssi.local;
 	while (cur) {
 		del = cur;
 		cur = cur->next;
-		free(del->name);
+		g_free(del->name);
 		aim_tlvlist_free(&del->data);
-		free(del);
+		g_free(del);
 	}
 
 	curtmp = od->ssi.pending;
 	while (curtmp) {
 		deltmp = curtmp;
 		curtmp = curtmp->next;
-		free(deltmp);
+		g_free(deltmp);
 	}
 
 	od->ssi.numitems = 0;
@@ -672,7 +672,7 @@
 			char *alias = aim_ssi_getalias(od->ssi.local, NULL, cur->name);
 			aim_ssi_addbuddy(od, cur->name, "orphans", alias, NULL, NULL, 0);
 			aim_ssi_delbuddy(od, cur->name, NULL);
-			free(alias);
+			g_free(alias);
 		}
 		cur = next;
 	}
@@ -929,7 +929,7 @@
 	aim_ssi_delbuddy(od, sn, oldgn);
 	aim_ssi_addbuddy(od, sn, newgn, alias, NULL, NULL, waitingforauth);
 
-	free(alias);
+	g_free(alias);
 
 	return 0;
 }
@@ -1012,8 +1012,8 @@
 	if (!(group = aim_ssi_itemlist_finditem(od->ssi.local, oldgn, NULL, AIM_SSI_TYPE_GROUP)))
 		return -EINVAL;
 
-	free(group->name);
-	group->name = (char *)malloc((strlen(newgn)+1)*sizeof(char));
+	g_free(group->name);
+	group->name = (char *)g_malloc((strlen(newgn)+1)*sizeof(char));
 	strcpy(group->name, newgn);
 
 	/* Sync our local list with the server list */
@@ -1086,12 +1086,12 @@
 	}
 
 	/* Need to add the 0x00d5 TLV to the TLV chain */
-	csumdata = (guint8 *)malloc((iconsumlen+2)*sizeof(guint8));
+	csumdata = (guint8 *)g_malloc((iconsumlen+2)*sizeof(guint8));
 	aimutil_put8(&csumdata[0], 0x00);
 	aimutil_put8(&csumdata[1], iconsumlen);
 	memcpy(&csumdata[2], iconsum, iconsumlen);
 	aim_tlvlist_replace_raw(&tmp->data, 0x00d5, (iconsumlen+2) * sizeof(guint8), csumdata);
-	free(csumdata);
+	g_free(csumdata);
 
 	/* Need to add the 0x0131 TLV to the TLV chain, used to cache the icon */
 	aim_tlvlist_replace_noval(&tmp->data, 0x0131);
@@ -1188,7 +1188,7 @@
 
 	byte_stream_init(&bstream, tlv->value, tlv->length);
 
-	maxitems = (guint16 *)malloc((tlv->length/2)*sizeof(guint16));
+	maxitems = (guint16 *)g_malloc((tlv->length/2)*sizeof(guint16));
 
 	for (i=0; i<(tlv->length/2); i++)
 		maxitems[i] = byte_stream_get16(&bstream);
@@ -1197,7 +1197,7 @@
 		ret = userfunc(od, conn, frame, tlv->length/2, maxitems);
 
 	aim_tlvlist_free(&tlvlist);
-	free(maxitems);
+	g_free(maxitems);
 
 	return ret;
 }
@@ -1283,7 +1283,7 @@
 		type = byte_stream_get16(bs);
 		data = aim_tlvlist_readlen(bs, byte_stream_get16(bs));
 		aim_ssi_itemlist_add(&od->ssi.official, name, gid, bid, type, data);
-		free(name);
+		g_free(name);
 		aim_tlvlist_free(&data);
 	}
 
@@ -1411,7 +1411,7 @@
 		if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 			ret = userfunc(od, conn, frame, type, name);
 
-		free(name);
+		g_free(name);
 	}
 
 	return ret;
@@ -1447,9 +1447,9 @@
 		/* Replace the 2 local items with the given one */
 		if ((item = aim_ssi_itemlist_find(od->ssi.local, gid, bid))) {
 			item->type = type;
-			free(item->name);
+			g_free(item->name);
 			if (name) {
-				item->name = (char *)malloc((strlen(name)+1)*sizeof(char));
+				item->name = (char *)g_malloc((strlen(name)+1)*sizeof(char));
 				strcpy(item->name, name);
 			} else
 				item->name = NULL;
@@ -1459,9 +1459,9 @@
 
 		if ((item = aim_ssi_itemlist_find(od->ssi.official, gid, bid))) {
 			item->type = type;
-			free(item->name);
+			g_free(item->name);
 			if (name) {
-				item->name = (char *)malloc((strlen(name)+1)*sizeof(char));
+				item->name = (char *)g_malloc((strlen(name)+1)*sizeof(char));
 				strcpy(item->name, name);
 			} else
 				item->name = NULL;
@@ -1472,7 +1472,7 @@
 		if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 			ret = userfunc(od, conn, frame);
 
-		free(name);
+		g_free(name);
 		aim_tlvlist_free(&data);
 	}
 
@@ -1543,7 +1543,7 @@
 				/* Make sure cur->item is still valid memory */
 				if (aim_ssi_itemlist_valid(od->ssi.local, cur->item)) {
 					if (cur->item->name) {
-						cur->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
+						cur->name = (char *)g_malloc((strlen(cur->item->name)+1)*sizeof(char));
 						strcpy(cur->name, cur->item->name);
 					}
 					aim_ssi_itemlist_del(&od->ssi.local, cur->item);
@@ -1555,9 +1555,9 @@
 				if (aim_ssi_itemlist_valid(od->ssi.local, cur->item)) {
 					struct aim_ssi_item *cur1;
 					if ((cur1 = aim_ssi_itemlist_find(od->ssi.official, cur->item->gid, cur->item->bid))) {
-						free(cur->item->name);
+						g_free(cur->item->name);
 						if (cur1->name) {
-							cur->item->name = (char *)malloc((strlen(cur1->name)+1)*sizeof(char));
+							cur->item->name = (char *)g_malloc((strlen(cur1->name)+1)*sizeof(char));
 							strcpy(cur->item->name, cur1->name);
 						} else
 							cur->item->name = NULL;
@@ -1589,9 +1589,9 @@
 				if (aim_ssi_itemlist_valid(od->ssi.local, cur->item)) {
 					struct aim_ssi_item *cur1;
 					if ((cur1 = aim_ssi_itemlist_find(od->ssi.official, cur->item->gid, cur->item->bid))) {
-						free(cur1->name);
+						g_free(cur1->name);
 						if (cur->item->name) {
-							cur1->name = (char *)malloc((strlen(cur->item->name)+1)*sizeof(char));
+							cur1->name = (char *)g_malloc((strlen(cur->item->name)+1)*sizeof(char));
 							strcpy(cur1->name, cur->item->name);
 						} else
 							cur1->name = NULL;
@@ -1620,8 +1620,8 @@
 	while (cur && (cur->ack != 0xffff)) {
 		del = cur;
 		cur = cur->next;
-		free(del->name);
-		free(del);
+		g_free(del->name);
+		g_free(del);
 	}
 	od->ssi.pending = cur;
 
@@ -1757,8 +1757,8 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, sn, msg);
 
-	free(sn);
-	free(msg);
+	g_free(sn);
+	g_free(msg);
 
 	return ret;
 }
@@ -1831,8 +1831,8 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, sn, msg);
 
-	free(sn);
-	free(msg);
+	g_free(sn);
+	g_free(msg);
 
 	return ret;
 }
@@ -1918,8 +1918,8 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, sn, reply, msg);
 
-	free(sn);
-	free(msg);
+	g_free(sn);
+	g_free(msg);
 
 	return ret;
 }
@@ -1943,7 +1943,7 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, sn);
 
-	free(sn);
+	g_free(sn);
 
 	return ret;
 }
--- a/libpurple/protocols/oscar/family_icbm.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_icbm.c	Tue May 22 18:56:09 2007 +0000
@@ -468,16 +468,16 @@
 	aim_putsnac(&frame->data, 0x0004, 0x0006, 0x0000, snacid);
 
 	/* XXX should be uncached by an unwritten 'invite accept' handler */
-	priv = malloc(sizeof(struct aim_invite_priv));
-	priv->sn = strdup(sn);
-	priv->roomname = strdup(roomname);
+	priv = g_malloc(sizeof(struct aim_invite_priv));
+	priv->sn = g_strdup(sn);
+	priv->roomname = g_strdup(roomname);
 	priv->exchange = exchange;
 	priv->instance = instance;
 
 	if ((msgcookie = aim_mkcookie(cookie, AIM_COOKIETYPE_INVITE, priv)))
 		aim_cachecookie(od, msgcookie);
 	else
-		free(priv);
+		g_free(priv);
 
 	/* ICBM Header */
 	aim_im_puticbm(&frame->data, cookie, 0x0002, sn);
@@ -1279,8 +1279,8 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, channel, sn, msg, icbmflags, flag1, flag2);
 
-	free(sn);
-	free(msg);
+	g_free(sn);
+	g_free(msg);
 	aim_tlvlist_free(&tlvlist);
 
 	return ret;
@@ -1335,7 +1335,7 @@
 {
 	aim_mpmsg_section_t *sec;
 
-	sec = malloc(sizeof(aim_mpmsg_section_t));
+	sec = g_malloc(sizeof(aim_mpmsg_section_t));
 
 	sec->charset = charset;
 	sec->charsubset = charsubset;
@@ -1362,11 +1362,11 @@
 {
 	gchar *dup;
 
-	dup = malloc(datalen);
+	dup = g_malloc(datalen);
 	memcpy(dup, data, datalen);
 
 	if (mpmsg_addsection(od, mpm, charset, charsubset, dup, datalen) == -1) {
-		free(dup);
+		g_free(dup);
 		return -1;
 	}
 
@@ -1378,11 +1378,11 @@
 {
 	gchar *dup;
 
-	if (!(dup = strdup(ascii)))
+	if (!(dup = g_strdup(ascii)))
 		return -1;
 
 	if (mpmsg_addsection(od, mpm, 0x0000, 0x0000, dup, strlen(ascii)) == -1) {
-		free(dup);
+		g_free(dup);
 		return -1;
 	}
 
@@ -1395,7 +1395,7 @@
 	ByteStream bs;
 	int i;
 
-	buf = malloc(unicodelen * 2);
+	buf = g_malloc(unicodelen * 2);
 
 	byte_stream_init(&bs, (guchar *)buf, unicodelen * 2);
 
@@ -1404,7 +1404,7 @@
 		byte_stream_put16(&bs, unicode[i]);
 
 	if (mpmsg_addsection(od, mpm, 0x0002, 0x0000, buf, byte_stream_curpos(&bs)) == -1) {
-		free(buf);
+		g_free(buf);
 		return -1;
 	}
 
@@ -1419,8 +1419,8 @@
 		aim_mpmsg_section_t *tmp;
 
 		tmp = cur->next;
-		free(cur->data);
-		free(cur);
+		g_free(cur->data);
+		g_free(cur);
 		cur = tmp;
 	}
 
@@ -1659,7 +1659,7 @@
 				purple_debug_misc("oscar", "Received an IM containing an invalid message part from %s.  They are probably trying to do something malicious.\n", userinfo->sn);
 				break;
 			}
-			free(args.extdata);
+			g_free(args.extdata);
 			args.extdatalen = length;
 			if (args.extdatalen == 0)
 				args.extdata = NULL;
@@ -1686,8 +1686,8 @@
 		ret = userfunc(od, conn, frame, channel, userinfo, &args);
 
 	aim_mpmsg_free(od, &args.mpmsg);
-	free(args.features);
-	free(args.extdata);
+	g_free(args.features);
+	g_free(args.extdata);
 
 	return ret;
 }
@@ -1733,10 +1733,10 @@
 
 			purple_debug_misc("oscar", "got a buddy list from %s: group %s, buddy %s\n", userinfo->sn, gn, bn);
 
-			free(bn);
+			g_free(bn);
 		}
 
-		free(gn);
+		g_free(gn);
 	}
 
 	return;
@@ -1745,7 +1745,7 @@
 static void
 incomingim_ch2_buddyicon_free(OscarData *od, IcbmArgsCh2 *args)
 {
-	free(args->info.icon.icon);
+	g_free(args->info.icon.icon);
 
 	return;
 }
@@ -1767,7 +1767,7 @@
 incomingim_ch2_chat_free(OscarData *od, IcbmArgsCh2 *args)
 {
 	/* XXX - aim_chat_roominfo_free() */
-	free(args->info.chat.roominfo.name);
+	g_free(args->info.chat.roominfo.name);
 
 	return;
 }
@@ -1786,7 +1786,7 @@
 static void
 incomingim_ch2_icqserverrelay_free(OscarData *od, IcbmArgsCh2 *args)
 {
-	free((char *)args->info.rtfmsg.rtfmsg);
+	g_free((char *)args->info.rtfmsg.rtfmsg);
 }
 
 /*
@@ -1832,7 +1832,7 @@
 static void
 incomingim_ch2_sendfile_free(OscarData *od, IcbmArgsCh2 *args)
 {
-	free(args->info.sendfile.filename);
+	g_free(args->info.sendfile.filename);
 }
 
 /* Someone is sending us a file */
@@ -1918,11 +1918,11 @@
 	{
 		purple_debug_warning("oscar",
 				"Cookies don't match in rendezvous ICBM, bailing out.\n");
-		free(cookie2);
+		g_free(cookie2);
 		return 1;
 	}
 	memcpy(args.cookie, cookie2, 8);
-	free(cookie2);
+	g_free(cookie2);
 
 	/*
 	 * The next 16bytes are a capability block so we can
@@ -2074,9 +2074,9 @@
 	if (args.destructor)
 		((ch2_args_destructor_t)args.destructor)(od, &args);
 
-	free((char *)args.msg);
-	free((char *)args.encoding);
-	free((char *)args.language);
+	g_free((char *)args.msg);
+	g_free((char *)args.encoding);
+	g_free((char *)args.language);
 
 	aim_tlvlist_free(&list2);
 
@@ -2107,7 +2107,7 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, channel, userinfo, &args);
 
-	free(args.msg);
+	g_free(args.msg);
 
 	return ret;
 }
@@ -2210,7 +2210,7 @@
 	}
 
 	aim_info_free(&userinfo);
-	free(cookie);
+	g_free(cookie);
 
 	return ret;
 }
@@ -2379,7 +2379,7 @@
 				if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 					ret = userfunc(od, conn, frame, channel, sn, reason, state, msg);
 
-				free(msg);
+				g_free(msg);
 			} break;
 
 			default: {
@@ -2389,8 +2389,8 @@
 		} /* end switch */
 	}
 
-	free(cookie);
-	free(sn);
+	g_free(cookie);
+	g_free(sn);
 
 	return ret;
 }
@@ -2418,8 +2418,8 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, ch, sn);
 
-	free(sn);
-	free(cookie);
+	g_free(sn);
+	g_free(cookie);
 
 	return ret;
 }
@@ -2502,7 +2502,7 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, type1, sn, type2);
 
-	free(sn);
+	g_free(sn);
 
 	return ret;
 }
--- a/libpurple/protocols/oscar/family_icq.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_icq.c	Tue May 22 18:56:09 2007 +0000
@@ -212,7 +212,7 @@
 	flap_connection_send(conn, frame);
 
 	/* Keep track of this request and the ICQ number and request ID */
-	info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
+	info = (struct aim_icq_info *)g_new0(struct aim_icq_info, 1);
 	info->reqid = snacid;
 	info->uin = atoi(uin);
 	info->next = od->icq_info;
@@ -256,7 +256,7 @@
 	flap_connection_send(conn, frame);
 
 	/* Keep track of this request and the ICQ number and request ID */
-	info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
+	info = (struct aim_icq_info *)g_new0(struct aim_icq_info, 1);
 	info->reqid = snacid;
 	info->uin = atoi(uin);
 	info->next = od->icq_info;
@@ -426,7 +426,7 @@
 
 	flap_connection_send(conn, frame);
 
-	free(xml);
+	g_free(xml);
 
 	return 0;
 }
@@ -437,34 +437,34 @@
 
 	if (!info)
 		return;
-	free(info->nick);
-	free(info->first);
-	free(info->last);
-	free(info->email);
-	free(info->homecity);
-	free(info->homestate);
-	free(info->homephone);
-	free(info->homefax);
-	free(info->homeaddr);
-	free(info->mobile);
-	free(info->homezip);
-	free(info->personalwebpage);
+	g_free(info->nick);
+	g_free(info->first);
+	g_free(info->last);
+	g_free(info->email);
+	g_free(info->homecity);
+	g_free(info->homestate);
+	g_free(info->homephone);
+	g_free(info->homefax);
+	g_free(info->homeaddr);
+	g_free(info->mobile);
+	g_free(info->homezip);
+	g_free(info->personalwebpage);
 	if (info->email2)
 		for (i = 0; i < info->numaddresses; i++)
-			free(info->email2[i]);
-	free(info->email2);
-	free(info->workcity);
-	free(info->workstate);
-	free(info->workphone);
-	free(info->workfax);
-	free(info->workaddr);
-	free(info->workzip);
-	free(info->workcompany);
-	free(info->workdivision);
-	free(info->workposition);
-	free(info->workwebpage);
-	free(info->info);
-	free(info);
+			g_free(info->email2[i]);
+	g_free(info->email2);
+	g_free(info->workcity);
+	g_free(info->workstate);
+	g_free(info->workphone);
+	g_free(info->workfax);
+	g_free(info->workaddr);
+	g_free(info->workzip);
+	g_free(info->workcompany);
+	g_free(info->workdivision);
+	g_free(info->workposition);
+	g_free(info->workwebpage);
+	g_free(info->info);
+	g_free(info);
 }
 
 /**
@@ -515,7 +515,7 @@
 		if ((userfunc = aim_callhandler(od, SNAC_FAMILY_ICQ, SNAC_SUBTYPE_ICQ_OFFLINEMSG)))
 			ret = userfunc(od, conn, frame, &msg);
 
-		free(msg.msg);
+		g_free(msg.msg);
 
 	} else if (cmd == 0x0042) {
 		aim_rxcallback_t userfunc;
@@ -534,7 +534,7 @@
 		/* find other data from the same request */
 		for (info = od->icq_info; info && (info->reqid != reqid); info = info->next);
 		if (!info) {
-			info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info));
+			info = (struct aim_icq_info *)g_new0(struct aim_icq_info, 1);
 			info->reqid = reqid;
 			info->next = od->icq_info;
 			od->icq_info = info;
@@ -603,7 +603,7 @@
 		case 0x00eb: { /* email address(es) */
 			int i;
 			info->numaddresses = byte_stream_getle16(&qbs);
-			info->email2 = (char **)calloc(info->numaddresses, sizeof(char *));
+			info->email2 = (char **)g_new0(char *, info->numaddresses);
 			for (i = 0; i < info->numaddresses; i++) {
 				info->email2[i] = byte_stream_getstr(&qbs, byte_stream_getle16(&qbs));
 				if (i+1 != info->numaddresses)
--- a/libpurple/protocols/oscar/family_locate.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_locate.c	Tue May 22 18:56:09 2007 +0000
@@ -238,8 +238,8 @@
 	cur = aim_locate_finduserinfo(od, userinfo->sn);
 
 	if (cur == NULL) {
-		cur = (aim_userinfo_t *)calloc(1, sizeof(aim_userinfo_t));
-		cur->sn = strdup(userinfo->sn);
+		cur = (aim_userinfo_t *)g_new0(aim_userinfo_t, 1);
+		cur->sn = g_strdup(userinfo->sn);
 		cur->next = od->locate.userinfo;
 		od->locate.userinfo = cur;
 	}
@@ -261,63 +261,63 @@
 	cur->present |= userinfo->present;
 
 	if (userinfo->iconcsumlen > 0) {
-		free(cur->iconcsum);
-		cur->iconcsum = (guint8 *)malloc(userinfo->iconcsumlen);
+		g_free(cur->iconcsum);
+		cur->iconcsum = (guint8 *)g_malloc(userinfo->iconcsumlen);
 		memcpy(cur->iconcsum, userinfo->iconcsum, userinfo->iconcsumlen);
 		cur->iconcsumlen = userinfo->iconcsumlen;
 	}
 
 	if (userinfo->info != NULL) {
-		free(cur->info);
-		free(cur->info_encoding);
+		g_free(cur->info);
+		g_free(cur->info_encoding);
 		if (userinfo->info_len > 0) {
-			cur->info = (char *)malloc(userinfo->info_len);
+			cur->info = (char *)g_malloc(userinfo->info_len);
 			memcpy(cur->info, userinfo->info, userinfo->info_len);
 		} else
 			cur->info = NULL;
-		cur->info_encoding = strdup(userinfo->info_encoding);
+		cur->info_encoding = g_strdup(userinfo->info_encoding);
 		cur->info_len = userinfo->info_len;
 	}
 
 	if (userinfo->status != NULL) {
-		free(cur->status);
-		free(cur->status_encoding);
+		g_free(cur->status);
+		g_free(cur->status_encoding);
 		if (userinfo->status_len > 0) {
-			cur->status = (char *)malloc(userinfo->status_len);
+			cur->status = (char *)g_malloc(userinfo->status_len);
 			memcpy(cur->status, userinfo->status, userinfo->status_len);
 		} else
 			cur->status = NULL;
 		if (userinfo->status_encoding != NULL)
-			cur->status_encoding = strdup(userinfo->status_encoding);
+			cur->status_encoding = g_strdup(userinfo->status_encoding);
 		else
 			cur->status_encoding = NULL;
 		cur->status_len = userinfo->status_len;
 	}
 
 	if (userinfo->itmsurl != NULL) {
-		free(cur->itmsurl);
-		free(cur->itmsurl_encoding);
+		g_free(cur->itmsurl);
+		g_free(cur->itmsurl_encoding);
 		if (userinfo->itmsurl_len > 0) {
-			cur->itmsurl = (char *)malloc(userinfo->itmsurl_len);
+			cur->itmsurl = (char *)g_malloc(userinfo->itmsurl_len);
 			memcpy(cur->itmsurl, userinfo->itmsurl, userinfo->itmsurl_len);
 		} else
 			cur->itmsurl = NULL;
 		if (userinfo->itmsurl_encoding != NULL)
-			cur->itmsurl_encoding = strdup(userinfo->itmsurl_encoding);
+			cur->itmsurl_encoding = g_strdup(userinfo->itmsurl_encoding);
 		else
 			cur->itmsurl_encoding = NULL;
 		cur->itmsurl_len = userinfo->itmsurl_len;
 	}
 
 	if (userinfo->away != NULL) {
-		free(cur->away);
-		free(cur->away_encoding);
+		g_free(cur->away);
+		g_free(cur->away_encoding);
 		if (userinfo->away_len > 0) {
-			cur->away = (char *)malloc(userinfo->away_len);
+			cur->away = (char *)g_malloc(userinfo->away_len);
 			memcpy(cur->away, userinfo->away, userinfo->away_len);
 		} else
 			cur->away = NULL;
-		cur->away_encoding = strdup(userinfo->away_encoding);
+		cur->away_encoding = g_strdup(userinfo->away_encoding);
 		cur->away_len = userinfo->away_len;
 
 	} else if (!(userinfo->flags & AIM_FLAG_AWAY)) {
@@ -326,11 +326,11 @@
 		 * If the user is not away, clear any cached away message now.
 		 */
 		if (cur->away) {
-			free(cur->away);
+			g_free(cur->away);
 			cur->away = NULL;
 		}
 		if (cur->away_encoding) {
-			free(cur->away_encoding);
+			g_free(cur->away_encoding);
 			cur->away_encoding = NULL;
 		}
 		cur->away_len = 0;
@@ -401,8 +401,8 @@
 		del = od->locate.requested;
 		od->locate.requested = del->next;
 		was_explicit = FALSE;
-		free(del->sn);
-		free(del);
+		g_free(del->sn);
+		g_free(del);
 	}
 
 	cur = od->locate.requested;
@@ -411,8 +411,8 @@
 			del = cur->next;
 			cur->next = del->next;
 			was_explicit = FALSE;
-			free(del->sn);
-			free(del);
+			g_free(del->sn);
+			g_free(del);
 		} else
 			cur = cur->next;
 	}
@@ -447,8 +447,8 @@
 	}
 
 	/* Add a new node to our request queue */
-	cur = (struct userinfo_node *)malloc(sizeof(struct userinfo_node));
-	cur->sn = strdup(sn);
+	cur = (struct userinfo_node *)g_malloc(sizeof(struct userinfo_node));
+	cur->sn = g_strdup(sn);
 	cur->next = od->locate.torequest;
 	od->locate.torequest = cur;
 
@@ -502,7 +502,7 @@
 					cap[10], cap[11], cap[12], cap[13],
 					cap[14], cap[15]);
 
-		free(cap);
+		g_free(cap);
 	}
 
 	return flags;
@@ -531,7 +531,7 @@
 		if (!identified)
 			purple_debug_misc("oscar", "unknown short capability: {%02x%02x}\n", cap[0], cap[1]);
 
-		free(cap);
+		g_free(cap);
 	}
 
 	return flags;
@@ -586,16 +586,16 @@
 void
 aim_info_free(aim_userinfo_t *info)
 {
-	free(info->sn);
-	free(info->iconcsum);
-	free(info->info);
-	free(info->info_encoding);
-	free(info->status);
-	free(info->status_encoding);
-	free(info->itmsurl);
-	free(info->itmsurl_encoding);
-	free(info->away);
-	free(info->away_encoding);
+	g_free(info->sn);
+	g_free(info->iconcsum);
+	g_free(info->info);
+	g_free(info->info_encoding);
+	g_free(info->status);
+	g_free(info->status_encoding);
+	g_free(info->itmsurl);
+	g_free(info->itmsurl_encoding);
+	g_free(info->away);
+	g_free(info->away_encoding);
 }
 
 /*
@@ -829,7 +829,7 @@
 
 					case 0x0001: { /* A buddy icon checksum */
 						if ((length2 > 0) && ((number == 0x00) || (number == 0x01))) {
-							free(outinfo->iconcsum);
+							g_free(outinfo->iconcsum);
 							outinfo->iconcsumtype = number;
 							outinfo->iconcsum = byte_stream_getraw(bs, length2);
 							outinfo->iconcsumlen = length2;
@@ -838,8 +838,8 @@
 					} break;
 
 					case 0x0002: { /* A status/available message */
-						free(outinfo->status);
-						free(outinfo->status_encoding);
+						g_free(outinfo->status);
+						g_free(outinfo->status_encoding);
 						if (length2 >= 4) {
 							outinfo->status_len = byte_stream_get16(bs);
 							outinfo->status = byte_stream_getstr(bs, outinfo->status_len);
@@ -859,8 +859,8 @@
 					} break;
 
 					case 0x0009: { /* An iTunes Music Store link */
-						free(outinfo->itmsurl);
-						free(outinfo->itmsurl_encoding);
+						g_free(outinfo->itmsurl);
+						g_free(outinfo->itmsurl_encoding);
 						if (length2 >= 4) {
 							outinfo->itmsurl_len = byte_stream_get16(bs);
 							outinfo->itmsurl = byte_stream_getstr(bs, outinfo->itmsurl_len);
@@ -1013,8 +1013,8 @@
 			ret = userfunc(od, conn, frame, reason, sn);
 
 	if (snac2)
-		free(snac2->data);
-	free(snac2);
+		g_free(snac2->data);
+	g_free(snac2);
 
 	return ret;
 }
@@ -1113,11 +1113,11 @@
 	/* Build the packet first to get real length */
 	if (profile) {
 		/* no + 1 here because of %s */
-		encoding = malloc(strlen(defencoding) + strlen(profile_encoding));
+		encoding = g_malloc(strlen(defencoding) + strlen(profile_encoding));
 		snprintf(encoding, strlen(defencoding) + strlen(profile_encoding), defencoding, profile_encoding);
 		aim_tlvlist_add_str(&tl, 0x0001, encoding);
 		aim_tlvlist_add_raw(&tl, 0x0002, profile_len, (const guchar *)profile);
-		free(encoding);
+		g_free(encoding);
 	}
 
 	/*
@@ -1130,11 +1130,11 @@
 	 */
 	if (awaymsg) {
 		if (awaymsg_len) {
-			encoding = malloc(strlen(defencoding) + strlen(awaymsg_encoding));
+			encoding = g_malloc(strlen(defencoding) + strlen(awaymsg_encoding));
 			snprintf(encoding, strlen(defencoding) + strlen(awaymsg_encoding), defencoding, awaymsg_encoding);
 			aim_tlvlist_add_str(&tl, 0x0003, encoding);
 			aim_tlvlist_add_raw(&tl, 0x0004, awaymsg_len, (const guchar *)awaymsg);
-			free(encoding);
+			g_free(encoding);
 		} else
 			aim_tlvlist_add_noval(&tl, 0x0004);
 	}
@@ -1225,14 +1225,14 @@
 	aim_tlv_t *tlv = NULL;
 	int was_explicit;
 
-	userinfo = (aim_userinfo_t *)malloc(sizeof(aim_userinfo_t));
+	userinfo = (aim_userinfo_t *)g_malloc(sizeof(aim_userinfo_t));
 	aim_info_extract(od, bs, userinfo);
 	tlvlist = aim_tlvlist_read(bs);
 
 	/* Profile will be 1 and 2 */
 	userinfo->info_encoding = aim_tlv_getstr(tlvlist, 0x0001, 1);
 	if ((tlv = aim_tlv_gettlv(tlvlist, 0x0002, 1))) {
-		userinfo->info = (char *)malloc(tlv->length);
+		userinfo->info = (char *)g_malloc(tlv->length);
 		memcpy(userinfo->info, tlv->value, tlv->length);
 		userinfo->info_len = tlv->length;
 	}
@@ -1240,7 +1240,7 @@
 	/* Away message will be 3 and 4 */
 	userinfo->away_encoding = aim_tlv_getstr(tlvlist, 0x0003, 1);
 	if ((tlv = aim_tlv_gettlv(tlvlist, 0x0004, 1))) {
-		userinfo->away = (char *)malloc(tlv->length);
+		userinfo->away = (char *)g_malloc(tlv->length);
 		memcpy(userinfo->away, tlv->value, tlv->length);
 		userinfo->away_len = tlv->length;
 	}
@@ -1257,7 +1257,7 @@
 	aim_locate_adduserinfo(od, userinfo);
 	userinfo2 = aim_locate_finduserinfo(od, userinfo->sn);
 	aim_info_free(userinfo);
-	free(userinfo);
+	g_free(userinfo);
 
 	/*
 	 * Remove this screen name from our queue.  If the client requested
@@ -1454,7 +1454,7 @@
 		del = od->locate.userinfo;
 		od->locate.userinfo = od->locate.userinfo->next;
 		aim_info_free(del);
-		free(del);
+		g_free(del);
 	}
 }
 
--- a/libpurple/protocols/oscar/family_odir.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_odir.c	Tue May 22 18:56:09 2007 +0000
@@ -190,7 +190,7 @@
 	while (numresults) {
 		struct aim_odir *new;
 		aim_tlvlist_t *tl = aim_tlvlist_readnum(bs, byte_stream_get16(bs));
-		new = (struct aim_odir *)malloc(sizeof(struct aim_odir));
+		new = (struct aim_odir *)g_malloc(sizeof(struct aim_odir));
 		new->first = aim_tlv_getstr(tl, 0x0001, 1);
 		new->last = aim_tlv_getstr(tl, 0x0002, 1);
 		new->middle = aim_tlv_getstr(tl, 0x0003, 1);
@@ -217,21 +217,21 @@
 	while (results) {
 		struct aim_odir *del = results;
 		results = results->next;
-		free(del->first);
-		free(del->last);
-		free(del->middle);
-		free(del->maiden);
-		free(del->email);
-		free(del->country);
-		free(del->state);
-		free(del->city);
-		free(del->sn);
-		free(del->interest);
-		free(del->nick);
-		free(del->zip);
-		free(del->region);
-		free(del->address);
-		free(del);
+		g_free(del->first);
+		g_free(del->last);
+		g_free(del->middle);
+		g_free(del->maiden);
+		g_free(del->email);
+		g_free(del->country);
+		g_free(del->state);
+		g_free(del->city);
+		g_free(del->sn);
+		g_free(del->interest);
+		g_free(del->nick);
+		g_free(del->zip);
+		g_free(del->region);
+		g_free(del->address);
+		g_free(del);
 	}
 
 	return ret;
--- a/libpurple/protocols/oscar/family_oservice.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_oservice.c	Tue May 22 18:56:09 2007 +0000
@@ -194,12 +194,12 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, &redir);
 
-	free((void *)redir.ip);
-	free((void *)redir.cookie);
+	g_free((void *)redir.ip);
+	g_free((void *)redir.cookie);
 
 	if (origsnac)
-		free(origsnac->data);
-	free(origsnac);
+		g_free(origsnac->data);
+	g_free(origsnac);
 
 	aim_tlvlist_free(&tlvlist);
 
@@ -588,7 +588,7 @@
 	conn = flap_connection_findbygroup(od, SNAC_FAMILY_BOS);
 	if(!conn)
 		return;
-	
+
 	aim_genericreq_l(od, conn, 0x0001, 0x0011, &idletime);
 }
 
@@ -641,7 +641,7 @@
 		ret = userfunc(od, conn, frame, ip, cktlv ? cktlv->value : NULL);
 
 	aim_tlvlist_free(&tl);
-	free(ip);
+	g_free(ip);
 
 	return ret;
 }
@@ -679,7 +679,7 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, id, msg);
 
-	free(msg);
+	g_free(msg);
 
 	aim_tlvlist_free(&tlvlist);
 
@@ -769,7 +769,7 @@
 	/* This is frivolous. (Thank you SmarterChild.) */
 	vercount = byte_stream_empty(bs)/4;
 	versions = byte_stream_getraw(bs, byte_stream_empty(bs));
-	free(versions);
+	g_free(versions);
 
 	/*
 	 * Now request rates.
@@ -927,7 +927,7 @@
 	if ((userfunc = aim_callhandler(od, snac->family, snac->subtype)))
 		ret = userfunc(od, conn, frame, offset, len, modname);
 
-	free(modname);
+	g_free(modname);
 	aim_tlvlist_free(&list);
 
 	return ret;
@@ -1051,13 +1051,13 @@
 			/* not sure what the difference between 1 and 0 is */
 			guint8 *md5 = byte_stream_getraw(bs, length);
 			ret = userfunc(od, conn, frame, type, flags, length, md5);
-			free(md5);
+			g_free(md5);
 			} break;
 		case 0x0002: { /* available message */
 			/* there is a second length that is just for the message */
 			char *msg = byte_stream_getstr(bs, byte_stream_get16(bs));
 			ret = userfunc(od, conn, frame, msg);
-			free(msg);
+			g_free(msg);
 			} break;
 		}
 	}
--- a/libpurple/protocols/oscar/family_popup.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_popup.c	Tue May 22 18:56:09 2007 +0000
@@ -54,8 +54,8 @@
 		ret = userfunc(od, conn, frame, msg, url, width, height, delay);
 
 	aim_tlvlist_free(&tl);
-	free(msg);
-	free(url);
+	g_free(msg);
+	g_free(url);
 
 	return ret;
 }
--- a/libpurple/protocols/oscar/family_userlookup.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/family_userlookup.c	Tue May 22 18:56:09 2007 +0000
@@ -49,8 +49,8 @@
 
 	/* XXX freesnac()? */
 	if (snac2)
-		free(snac2->data);
-	free(snac2);
+		g_free(snac2->data);
+	g_free(snac2);
 
 	return ret;
 }
@@ -107,14 +107,14 @@
 	 */
 	while ((cur = aim_tlv_getstr(tlvlist, 0x0001, j+1)) && j < m)
 	{
-		buf = realloc(buf, (j+1) * (MAXSNLEN+1));
+		buf = g_realloc(buf, (j+1) * (MAXSNLEN+1));
 
 		strncpy(&buf[j * (MAXSNLEN+1)], cur, MAXSNLEN);
-		free(cur);
+		g_free(cur);
 
 		j++;
 	}
-	free(cur);
+	g_free(cur);
 
 	aim_tlvlist_free(&tlvlist);
 
@@ -123,10 +123,10 @@
 
 	/* XXX freesnac()? */
 	if (snac2)
-		free(snac2->data);
-	free(snac2);
+		g_free(snac2->data);
+	g_free(snac2);
 
-	free(buf);
+	g_free(buf);
 
 	return ret;
 }
--- a/libpurple/protocols/oscar/flap_connection.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/flap_connection.c	Tue May 22 18:56:09 2007 +0000
@@ -723,7 +723,7 @@
 
 	aim_tlvlist_free(&tlvlist);
 
-	free(msg);
+	g_free(msg);
 }
 
 /**
--- a/libpurple/protocols/oscar/misc.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/misc.c	Tue May 22 18:56:09 2007 +0000
@@ -128,8 +128,8 @@
 		ret = userfunc(od, conn, frame, error, snac2 ? snac2->data : NULL);
 
 	if (snac2)
-		free(snac2->data);
-	free(snac2);
+		g_free(snac2->data);
+	g_free(snac2);
 
 	return ret;
 }
--- a/libpurple/protocols/oscar/msgcookie.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/msgcookie.c	Tue May 22 18:56:09 2007 +0000
@@ -113,7 +113,7 @@
 	if (!c)
 		return NULL;
 
-	cookie = calloc(1, sizeof(IcbmCookie));
+	cookie = g_new0(IcbmCookie, 1);
 
 	cookie->data = data;
 	cookie->type = type;
@@ -172,8 +172,8 @@
 			prev = &cur->next;
 	}
 
-	free(cookie->data);
-	free(cookie);
+	g_free(cookie->data);
+	g_free(cookie);
 
 	return 0;
 }
--- a/libpurple/protocols/oscar/oft.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/oft.c	Tue May 22 18:56:09 2007 +0000
@@ -568,7 +568,7 @@
 			break;
 	}
 
-	free(frame.name);
+	g_free(frame.name);
 }
 
 /*******************************************************************/
--- a/libpurple/protocols/oscar/rxhandlers.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/rxhandlers.c	Tue May 22 18:56:09 2007 +0000
@@ -55,14 +55,14 @@
 	mod = g_new0(aim_module_t, 1);
 
 	if (modfirst(od, mod) == -1) {
-		free(mod);
+		g_free(mod);
 		return -1;
 	}
 
 	if (aim__findmodule(od, mod->name)) {
 		if (mod->shutdown)
 			mod->shutdown(od, mod);
-		free(mod);
+		g_free(mod);
 		return -1;
 	}
 
@@ -86,7 +86,7 @@
 		if (cur->shutdown)
 			cur->shutdown(od, cur);
 
-		free(cur);
+		g_free(cur);
 
 		cur = tmp;
 	}
--- a/libpurple/protocols/oscar/snac.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/snac.c	Tue May 22 18:56:09 2007 +0000
@@ -57,7 +57,7 @@
 	snac.flags = flags;
 
 	if (datalen) {
-		if (!(snac.data = malloc(datalen)))
+		if (!(snac.data = g_malloc(datalen)))
 			return 0; /* er... */
 		memcpy(snac.data, data, datalen);
 	} else
@@ -78,7 +78,7 @@
 	if (!newsnac)
 		return 0;
 
-	if (!(snac = malloc(sizeof(aim_snac_t))))
+	if (!(snac = g_malloc(sizeof(aim_snac_t))))
 		return 0;
 	memcpy(snac, newsnac, sizeof(aim_snac_t));
 	snac->issuetime = time(NULL);
@@ -109,7 +109,7 @@
 		if (cur->id == id) {
 			*prev = cur->next;
 			if (cur->flags & AIM_SNACFLAGS_DESTRUCTOR) {
-				free(cur->data);
+				g_free(cur->data);
 				cur->data = NULL;
 			}
 			return cur;
@@ -145,8 +145,8 @@
 
 				*prev = cur->next;
 
-				free(cur->data);
-				free(cur);
+				g_free(cur->data);
+				g_free(cur);
 			} else
 				prev = &cur->next;
 		}
--- a/libpurple/protocols/oscar/tlv.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/tlv.c	Tue May 22 18:56:09 2007 +0000
@@ -41,8 +41,8 @@
 	if (!oldtlv || !*oldtlv)
 		return;
 
-	free((*oldtlv)->value);
-	free(*oldtlv);
+	g_free((*oldtlv)->value);
+	g_free(*oldtlv);
 	*oldtlv = NULL;
 
 	return;
@@ -103,7 +103,7 @@
 				cur->tlv->value = byte_stream_getraw(bs, length);
 				if (!cur->tlv->value) {
 					freetlv(&cur->tlv);
-					free(cur);
+					g_free(cur);
 					aim_tlvlist_free(&list);
 					return NULL;
 				}
@@ -159,7 +159,7 @@
 			cur->tlv->value = byte_stream_getraw(bs, length);
 			if (!cur->tlv->value) {
 				freetlv(&cur->tlv);
-				free(cur);
+				g_free(cur);
 				aim_tlvlist_free(&list);
 				return NULL;
 			}
@@ -216,7 +216,7 @@
 			cur->tlv->value = byte_stream_getraw(bs, length);
 			if (!cur->tlv->value) {
 				freetlv(&cur->tlv);
-				free(cur);
+				g_free(cur);
 				aim_tlvlist_free(&list);
 				return NULL;
 			}
@@ -271,8 +271,8 @@
 	aim_tlvlist_write(&bs2, &two);
 
 	if (memcmp(bs1.data, bs2.data, bs1.len)) {
-		free(bs1.data);
-		free(bs2.data);
+		g_free(bs1.data);
+		g_free(bs2.data);
 		return 1;
 	}
 
@@ -304,7 +304,7 @@
 		freetlv(&cur->tlv);
 
 		tmp = cur->next;
-		free(cur);
+		g_free(cur);
 		cur = tmp;
 	}
 
@@ -600,7 +600,7 @@
 	if (cur == NULL)
 		return aim_tlvlist_add_raw(list, type, length, value);
 
-	free(cur->tlv->value);
+	g_free(cur->tlv->value);
 	cur->tlv->length = length;
 	if (cur->tlv->length > 0) {
 		cur->tlv->value = g_memdup(value, length);
@@ -705,9 +705,9 @@
 	}
 
 	/* Free the removed item */
-	free(del->tlv->value);
-	free(del->tlv);
-	free(del);
+	g_free(del->tlv->value);
+	g_free(del->tlv);
+	g_free(del);
 }
 
 /**
@@ -808,7 +808,7 @@
 {
 	char *ret;
 
-	ret = malloc(tlv->length + 1);
+	ret = g_malloc(tlv->length + 1);
 	memcpy(ret, tlv->value, tlv->length);
 	ret[tlv->length] = '\0';
 
--- a/libpurple/protocols/oscar/util.c	Tue May 22 13:00:00 2007 +0000
+++ b/libpurple/protocols/oscar/util.c	Tue May 22 18:56:09 2007 +0000
@@ -101,14 +101,14 @@
 	next = strchr(last, dl);
 
 	if (curCount < theindex) {
-		toReturn = malloc(sizeof(char));
+		toReturn = g_malloc(sizeof(char));
 		*toReturn = '\0';
 	} else {
 		if (next == NULL) {
-			toReturn = malloc((strlen(last) + 1) * sizeof(char));
+			toReturn = g_malloc((strlen(last) + 1) * sizeof(char));
 			strcpy(toReturn, last);
 		} else {
-			toReturn = malloc((next - last + 1) * sizeof(char));
+			toReturn = g_malloc((next - last + 1) * sizeof(char));
 			memcpy(toReturn, last, (next - last));
 			toReturn[next - last] = '\0';
 		}