changeset 7162:d14e026611c0

[gaim-migrate @ 7729] constificating the countryside committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 05 Oct 2003 18:32:43 +0000
parents 3471c3b1e85c
children 3785d534d085
files src/blist.c src/protocols/msn/notification.c src/protocols/oscar/oscar.c src/util.c src/util.h
diffstat 5 files changed, 51 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/blist.c	Sun Oct 05 17:51:09 2003 +0000
+++ b/src/blist.c	Sun Oct 05 18:32:43 2003 +0000
@@ -681,10 +681,11 @@
 
 		if(bnode->parent->parent != (GaimBlistNode*)g) {
 			hb = g_new(struct _gaim_hbuddy, 1);
-			hb->name = gaim_normalize(buddy->name);
+			hb->name = g_strdup(gaim_normalize(buddy->name));
 			hb->account = buddy->account;
 			hb->group = bnode->parent->parent;
 			g_hash_table_remove(gaimbuddylist->buddies, hb);
+			g_free(hb->name);
 			g_free(hb);
 		}
 
@@ -1033,10 +1034,11 @@
 	}
 
 
-	hb.name = gaim_normalize(buddy->name);
+	hb.name = g_strdup(gaim_normalize(buddy->name));
 	hb.account = buddy->account;
 	hb.group = ((GaimBlistNode*)buddy)->parent->parent;
 	g_hash_table_remove(gaimbuddylist->buddies, &hb);
+	g_free(hb.name);
 
 	if(buddy->timer > 0)
 		g_source_remove(buddy->timer);
@@ -1202,15 +1204,18 @@
 	if (!name)
 		return NULL;
 
-	hb.name = gaim_normalize(name);
+	hb.name = g_strdup(gaim_normalize(name));
 	hb.account = account;
 
 	for(group = gaimbuddylist->root; group; group = group->next) {
 		hb.group = group;
-		if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb)) != NULL)
+		if ((buddy = g_hash_table_lookup(gaimbuddylist->buddies, &hb))) {
+			g_free(hb.name);
 			return buddy;
+		}
 	}
 
+	g_free(hb.name);
 	return NULL;
 }
 
@@ -1218,6 +1223,7 @@
 		GaimGroup *group)
 {
 	struct _gaim_hbuddy hb;
+	GaimBuddy *ret;
 
 	if (!gaimbuddylist)
 		return NULL;
@@ -1225,11 +1231,13 @@
 	if (!name)
 		return NULL;
 
-	hb.name = gaim_normalize(name);
+	hb.name = g_strdup(gaim_normalize(name));
 	hb.account = account;
 	hb.group = (GaimBlistNode*)group;
 
-	return g_hash_table_lookup(gaimbuddylist->buddies, &hb);
+	ret = g_hash_table_lookup(gaimbuddylist->buddies, &hb);
+	g_free(hb.name);
+	return ret;
 }
 
 GSList *gaim_find_buddies(GaimAccount *account, const char *name)
@@ -1245,7 +1253,7 @@
 	if (!name)
 		return NULL;
 
-	hb.name = gaim_normalize(name);
+	hb.name = g_strdup(gaim_normalize(name));
 	hb.account = account;
 
 	for(group = gaimbuddylist->root; group; group = group->next) {
@@ -1254,6 +1262,7 @@
 			ret = g_slist_append(ret, buddy);
 	}
 
+	g_free(hb.name);
 	return ret;
 }
 
--- a/src/protocols/msn/notification.c	Sun Oct 05 17:51:09 2003 +0000
+++ b/src/protocols/msn/notification.c	Sun Oct 05 18:32:43 2003 +0000
@@ -421,7 +421,7 @@
 	}
 	else if (strstr(buffer, "HTTP/1.1 401 Unauthorized") != NULL)
 	{
-		char *error;
+		const char *error;
 
 		if ((error = strstr(buffer, "WWW-Authenticate")) != NULL)
 		{
@@ -883,7 +883,7 @@
 	MsnPermitAdd *pa;
 	GSList *sl;
 	const char *list, *passport, *group_id = NULL;
-	char *friend;
+	const char *friend;
 	char msg[MSN_BUF_LEN];
 
 	list     = params[1];
@@ -935,7 +935,7 @@
 	MsnGroup *group;
 	MsnSession *session = servconn->session;
 	gint group_id;
-	char *group_name;
+	const char *group_name;
 
 	group_id = atoi(params[3]);
 
@@ -1554,7 +1554,7 @@
 {
 	MsnSession *session = servconn->session;
 	GaimConnection *gc = session->account->gc;
-	char *friend;
+	const char *friend;
 
 	friend = gaim_url_decode(params[3]);
 
@@ -1570,7 +1570,7 @@
 	MsnSession *session = servconn->session;
 	MsnGroup *group;
 	int group_id;
-	char *group_name;
+	const char *group_name;
 
 	group_id = atoi(params[2]);
 
--- a/src/protocols/oscar/oscar.c	Sun Oct 05 17:51:09 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Sun Oct 05 18:32:43 2003 +0000
@@ -3138,7 +3138,8 @@
 static int gaim_parse_userinfo(aim_session_t *sess, aim_frame_t *fr, ...) {
 	GaimConnection *gc = sess->aux_data;
 	GString *text;
-	gchar *info_utf8 = NULL, *away_utf8 = NULL, *final = NULL;
+	gchar *info_utf8 = NULL, *away_utf8 = NULL;
+	const char *final = NULL;
 	va_list ap;
 	aim_userinfo_t *userinfo;
 
@@ -3450,7 +3451,7 @@
 		if (b16) {
 			gaim_buddy_set_setting(b, "icon_checksum", b16);
 			gaim_blist_save();
-			free(b16);
+			g_free(b16);
 		}
 	}
 
@@ -4819,8 +4820,8 @@
 						gaim_blist_add_buddy(buddy, NULL, g, NULL);
 						export = TRUE;
 					}
-					free(gname_utf8);
-					free(alias_utf8);
+					g_free(gname_utf8);
+					g_free(alias_utf8);
 				}
 			} break;
 
@@ -5381,12 +5382,12 @@
 		}
 
 		if (userinfo != NULL) {
-			char *tstr = gaim_str_seconds_to_string(time(NULL) - userinfo->onlinesince + 
+			char *tstr = gaim_str_seconds_to_string(time(NULL) - userinfo->onlinesince +
 				(gc->login_time_official ? gc->login_time_official - gc->login_time : 0));
 			tmp = ret;
 			ret = g_strconcat(tmp, _("<b>Logged In:</b> "), tstr, "\n", NULL);
-			free(tmp);
-			free(tstr);
+			g_free(tmp);
+			g_free(tstr);
 		}
 
 		if ((bi != NULL) && (bi->ipaddr)) {
@@ -5397,22 +5398,22 @@
 							(bi->ipaddr & 0x000000ff));
 			tmp = ret;
 			ret = g_strconcat(tmp, _("<b>IP Address:</b> "), tstr, "\n", NULL);
-			free(tmp);
-			free(tstr);
+			g_free(tmp);
+			g_free(tstr);
 		}
 
 		if ((userinfo != NULL) && (userinfo->capabilities)) {
 			char *caps = caps_string(userinfo->capabilities);
 			tmp = ret;
 			ret = g_strconcat(tmp, _("<b>Capabilities:</b> "), caps, "\n", NULL);
-			free(tmp);
+			g_free(tmp);
 		}
 
 		if ((bi != NULL) && (bi->availmsg != NULL) && !(b->uc & UC_UNAVAILABLE)) {
 			gchar *escaped = g_markup_escape_text(bi->availmsg, strlen(bi->availmsg));
 			tmp = ret;
 			ret = g_strconcat(tmp, _("<b>Available:</b> "), escaped, "\n", NULL);
-			free(tmp);
+			g_free(tmp);
 			g_free(escaped);
 		}
 
@@ -5420,14 +5421,15 @@
 			gchar *away_utf8 = oscar_encoding_to_utf8(userinfo->away_encoding, userinfo->away, userinfo->away_len);
 			if (away_utf8 != NULL) {
 				gchar *tmp1, *tmp2;
+				const char *tmp3;
 				tmp1 = gaim_strreplace(away_utf8, "<BR>", "\n");
 				tmp2 = gaim_markup_strip_html(tmp1);
 				g_free(tmp1);
-				tmp1 = gaim_str_sub_away_formatters(tmp2, gaim_connection_get_display_name(gc));
+				tmp3 = gaim_str_sub_away_formatters(tmp2, gaim_connection_get_display_name(gc));
 				g_free(tmp2);
 				tmp = ret;
-				ret = g_strconcat(tmp, _("<b>Away Message:</b> "), tmp1, "\n", NULL);
-				free(tmp);
+				ret = g_strconcat(tmp, _("<b>Away Message:</b> "), tmp3, "\n", NULL);
+				g_free(tmp);
 				g_free(away_utf8);
 			}
 		}
--- a/src/util.c	Sun Oct 05 17:51:09 2003 +0000
+++ b/src/util.c	Sun Oct 05 18:32:43 2003 +0000
@@ -244,7 +244,7 @@
 /**************************************************************************
  * Date/Time Functions
  **************************************************************************/
-char *
+const char *
 gaim_date(void)
 {
 	static char date[80];
@@ -256,7 +256,7 @@
 	return date;
 }
 
-char *
+const char *
 gaim_date_full(void)
 {
 	char *date;
@@ -1249,7 +1249,7 @@
 /**************************************************************************
  * String Functions
  **************************************************************************/
-char *
+const char *
 gaim_normalize(const char *s)
 {
 	static char buf[BUF_LEN];
@@ -1278,7 +1278,7 @@
 
 /* Look for %n, %d, or %t in msg, and replace with the sender's name, date,
    or time */
-char *
+const char *
 gaim_str_sub_away_formatters(const char *msg, const char *name)
 {
 	char *c;
@@ -1918,7 +1918,7 @@
 	}
 }
 
-char *
+const char *
 gaim_url_decode(const char *str)
 {
 	static char buf[BUF_LEN];
@@ -1955,7 +1955,7 @@
 	return buf;
 }
 
-char *
+const char *
 gaim_url_encode(const char *str)
 {
 	static char buf[BUF_LEN];
@@ -2037,3 +2037,4 @@
 
 	return ret;
 }
+
--- a/src/util.h	Sun Oct 05 17:51:09 2003 +0000
+++ b/src/util.h	Sun Oct 05 18:32:43 2003 +0000
@@ -112,7 +112,7 @@
  *
  * @see gaim_date_full()
  */
-char *gaim_date(void);
+const char *gaim_date(void);
 
 /**
  * Returns the date and time in human-readable form.
@@ -124,7 +124,7 @@
  *
  * @see gaim_date()
  */
-char *gaim_date_full(void);
+const char *gaim_date_full(void);
 
 /**
  * Builds a time_t from the supplied information.
@@ -306,7 +306,7 @@
  *
  * @return A pointer to the normalized version stored in a static buffer.
  */
-char *gaim_normalize(const char *str);
+const char *gaim_normalize(const char *str);
 
 /**
  * Looks for %n, %d, or %t in a string, and replaces them with the
@@ -320,7 +320,7 @@
  *
  * @return A new string where the special variables are expanded.
  */
-char *gaim_str_sub_away_formatters(const char *str, const char *name);
+const char *gaim_str_sub_away_formatters(const char *str, const char *name);
 
 /**
  * Copies a string and replaces all HTML linebreaks with newline characters.
@@ -462,8 +462,8 @@
  * @param str The string to translate.
  *
  * @return The resulting string.
- */	
-char *gaim_url_decode(const char *str);
+ */
+const char *gaim_url_decode(const char *str);
 
 /**
  * Encodes a URL into an escaped string.
@@ -474,7 +474,7 @@
  *
  * @return The resulting string.
  */
-char *gaim_url_encode(const char *str);
+const char *gaim_url_encode(const char *str);
 
 /*@}*/