changeset 14032:49e020487c82

[gaim-migrate @ 16634] Do not waste too much unnecessary memory. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 05 Aug 2006 04:07:52 +0000
parents 942170284c55
children c070fdec12a3
files console/libgnt/gnttextview.c
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/console/libgnt/gnttextview.c	Sat Aug 05 03:20:14 2006 +0000
+++ b/console/libgnt/gnttextview.c	Sat Aug 05 04:07:52 2006 +0000
@@ -187,7 +187,6 @@
 	for (i = 0; split[i]; i++)
 	{
 		GntTextLine *line;
-		int len = g_utf8_strlen(split[i], -1);
 		char *iter = split[i];
 		int prev = 0;
 
@@ -202,8 +201,9 @@
 		while (iter && *iter)
 		{
 			GntTextSegment *seg = g_new0(GntTextSegment, 1);
+			int len = g_utf8_offset_to_pointer(iter, widget->priv.width - line->length - 1) - iter;
 			seg->flags = fl;
-			seg->text = g_new0(char, len + 1);		/* XXX: MUST be improved */
+			seg->text = g_new0(char, len + 1);
 			g_utf8_strncpy(seg->text, iter, widget->priv.width - line->length - 1);
 			line->segments = g_list_append(line->segments, seg);
 
@@ -215,7 +215,6 @@
 				line = g_new0(GntTextLine, 1);
 				view->list = g_list_prepend(g_list_first(view->list), line);
 			}
-			/*len -= prev;*/
 		}
 	}