changeset 29951:cb4eb163e3a4

oscar: g_malloc can't fail (in a way that doesn't abort)
author Paul Aurich <paul@darkrain42.org>
date Sun, 16 May 2010 05:57:08 +0000
parents e8b781c23fb6
children fb0245b8c177
files libpurple/protocols/oscar/snac.c
diffstat 1 files changed, 4 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/snac.c	Sat May 15 06:13:15 2010 +0000
+++ b/libpurple/protocols/oscar/snac.c	Sun May 16 05:57:08 2010 +0000
@@ -56,11 +56,9 @@
 	snac.type = type;
 	snac.flags = flags;
 
-	if (datalen) {
-		if (!(snac.data = g_malloc(datalen)))
-			return 0; /* er... */
-		memcpy(snac.data, data, datalen);
-	} else
+	if (datalen)
+		snac.data = g_memdup(data, datalen);
+	else
 		snac.data = NULL;
 
 	return aim_newsnac(od, &snac);
@@ -78,9 +76,7 @@
 	if (!newsnac)
 		return 0;
 
-	if (!(snac = g_malloc(sizeof(aim_snac_t))))
-		return 0;
-	memcpy(snac, newsnac, sizeof(aim_snac_t));
+	snac = g_memdup(newsnac, sizeof(aim_snac_t));
 	snac->issuetime = time(NULL);
 
 	index = snac->id % FAIM_SNAC_HASH_SIZE;