diff libpurple/protocols/msn/user.c @ 28961:08296b862f98

Move the three phone numbers from the MsnUser struct into a separate struct that gets added as needed. Makes MsnUser smaller by 2 pointers. In practice nobody has phone numbers
author Mark Doliner <mark@kingant.net>
date Thu, 04 Feb 2010 00:35:15 +0000
parents 99d1b433dba0
children 746bf7d8b34e
line wrap: on
line diff
--- a/libpurple/protocols/msn/user.c	Thu Feb 04 00:15:41 2010 +0000
+++ b/libpurple/protocols/msn/user.c	Thu Feb 04 00:35:15 2010 +0000
@@ -67,9 +67,12 @@
 	g_free(user->passport);
 	g_free(user->friendly_name);
 	g_free(user->uid);
-	g_free(user->phone.home);
-	g_free(user->phone.work);
-	g_free(user->phone.mobile);
+	if (user->phone) {
+		g_free(user->phone->home);
+		g_free(user->phone->work);
+		g_free(user->phone->mobile);
+		g_free(user->phone);
+	}
 	if (user->media) {
 		g_free(user->media->artist);
 		g_free(user->media->title);
@@ -367,8 +370,15 @@
 {
 	g_return_if_fail(user != NULL);
 
-	g_free(user->phone.home);
-	user->phone.home = g_strdup(number);
+	if (!number && !user->phone)
+		return;
+
+	if (user->phone)
+		g_free(user->phone->home);
+	else
+		user->phone = g_new0(MsnUserPhoneInfo, 1);
+
+	user->phone->home = g_strdup(number);
 }
 
 void
@@ -376,8 +386,15 @@
 {
 	g_return_if_fail(user != NULL);
 
-	g_free(user->phone.work);
-	user->phone.work = g_strdup(number);
+	if (!number && !user->phone)
+		return;
+
+	if (user->phone)
+		g_free(user->phone->work);
+	else
+		user->phone = g_new0(MsnUserPhoneInfo, 1);
+
+	user->phone->work = g_strdup(number);
 }
 
 void
@@ -385,8 +402,15 @@
 {
 	g_return_if_fail(user != NULL);
 
-	g_free(user->phone.mobile);
-	user->phone.mobile = g_strdup(number);
+	if (!number && !user->phone)
+		return;
+
+	if (user->phone)
+		g_free(user->phone->mobile);
+	else
+		user->phone = g_new0(MsnUserPhoneInfo, 1);
+
+	user->phone->mobile = g_strdup(number);
 }
 
 void
@@ -461,7 +485,7 @@
 {
 	g_return_val_if_fail(user != NULL, NULL);
 
-	return user->phone.home;
+	return user->phone ? user->phone->home : NULL;
 }
 
 const char *
@@ -469,7 +493,7 @@
 {
 	g_return_val_if_fail(user != NULL, NULL);
 
-	return user->phone.work;
+	return user->phone ? user->phone->work : NULL;
 }
 
 const char *
@@ -477,7 +501,7 @@
 {
 	g_return_val_if_fail(user != NULL, NULL);
 
-	return user->phone.mobile;
+	return user->phone ? user->phone->mobile : NULL;
 }
 
 guint