diff libpurple/protocols/myspace/myspace.c @ 25891:2260e5b0ca91

*** Plucked rev f9080d0b (khc@pidgin.im): correctly NULL terminate all the arrays since that's what gtknotify assumes, also fixed a memory leak in gmail notification *** Plucked rev a543de79 (khc@pidgin.im): Qulogic pointed out that glib has G_N_ELEMENTS already *** Plucked rev 19b202a7 (khc@pidgin.im): used the wrong count variable here
author Paul Aurich <paul@darkrain42.org>
date Sun, 10 May 2009 23:25:26 +0000
parents 7f552614ec8a
children 01f1929d0936
line wrap: on
line diff
--- a/libpurple/protocols/myspace/myspace.c	Wed May 06 18:58:47 2009 +0000
+++ b/libpurple/protocols/myspace/myspace.c	Sun May 10 23:25:26 2009 +0000
@@ -840,8 +840,6 @@
 	MsimMessage *body;
 	guint old_inbox_status;
 	guint i, n;
-	const gchar *froms[5], *tos[5], *urls[5], *subjects[5];
-
 	/* Information for each new inbox message type. */
 	static struct
 	{
@@ -856,16 +854,22 @@
 		{ "FriendRequest", MSIM_INBOX_FRIEND_REQUEST, "http://messaging.myspace.com/index.cfm?fuseaction=mail.friendRequests", NULL },
 		{ "PictureComment", MSIM_INBOX_PICTURE_COMMENT, "http://home.myspace.com/index.cfm?fuseaction=user", NULL }
 	};
+	const gchar *froms[G_N_ELEMENTS(message_types) + 1] = { "" },
+		*tos[G_N_ELEMENTS(message_types) + 1] = { "" },
+		*urls[G_N_ELEMENTS(message_types) + 1] = { "" },
+		*subjects[G_N_ELEMENTS(message_types) + 1] = { "" };
+
+	g_return_if_fail(reply != NULL);
 
 	/* Can't write _()'d strings in array initializers. Workaround. */
+	/* khc: then use N_() in the array initializer and use _() when they are
+	   used */
 	message_types[0].text = _("New mail messages");
 	message_types[1].text = _("New blog comments");
 	message_types[2].text = _("New profile comments");
 	message_types[3].text = _("New friend requests!");
 	message_types[4].text = _("New picture comments");
 
-	g_return_if_fail(reply != NULL);
-
 	body = msim_msg_get_dictionary(reply, "body");
 
 	if (body == NULL)
@@ -875,7 +879,7 @@
 
 	n = 0;
 
-	for (i = 0; i < sizeof(message_types) / sizeof(message_types[0]); ++i) {
+	for (i = 0; i < G_N_ELEMENTS(message_types); ++i) {
 		const gchar *key;
 		guint bit;