changeset 5341:ccec8893c1be

[gaim-migrate @ 5717] This fixes a memleak from my change last night. Thanks to Matt Pandina for pointing out that I'm dumb :-) Also, I made sec_to_text use g_strdup_printf instead of g_snprintf with a fixed sized buffer. Down with fixed size buffers everywhere! Ra ra ree! committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 09 May 2003 14:39:06 +0000
parents 986b2e4dae2d
children 8523e6797d47
files src/gtkblist.c src/util.c
diffstat 2 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/gtkblist.c	Fri May 09 06:27:51 2003 +0000
+++ b/src/gtkblist.c	Fri May 09 14:39:06 2003 +0000
@@ -844,11 +844,8 @@
 		if (!statustext && !GAIM_BUDDY_IS_ONLINE(b))
 			statustext = g_strdup(_("<b>Status:</b> Offline"));
 
-		if (b->idle > 0) {
-			time_t t;
-			time(&t);
-			idletime = g_strdup(sec_to_text(t-b->idle));
-		}
+		if (b->idle > 0)
+			idletime = sec_to_text(time(NULL) - b->idle);
 
 		if(b->alias && b->alias[0])
 			aliastext = g_markup_escape_text(b->alias, -1);
--- a/src/util.c	Fri May 09 06:27:51 2003 +0000
+++ b/src/util.c	Fri May 09 14:39:06 2003 +0000
@@ -93,7 +93,7 @@
 gchar *sec_to_text(guint sec)
 {
 	guint daze, hrs, min;
-	char *ret = g_malloc(256);
+	char *ret = NULL;
 
 	daze = sec / (60 * 60 * 24);
 	hrs = (sec % (60 * 60 * 24)) / (60 * 60);
@@ -104,33 +104,33 @@
 		if (hrs || min) {
 			if (hrs) {
 				if (min) {
-					g_snprintf(ret, 256,
+					ret = g_strdup_printf(
 						   "%d %s, %d %s, %d %s.",
 						   daze, ngettext("day","days",daze),
 						   hrs, ngettext("hour","hours",hrs), min, ngettext("minute","minutes",min));
 				} else {
-					g_snprintf(ret, 256,
+					ret = g_strdup_printf(
 						   "%d %s, %d %s.",
 						   daze, ngettext("day","days",daze), hrs, ngettext("hour","hours",hrs));
 				}
 			} else {
-				g_snprintf(ret, 256,
+				ret = g_strdup_printf(
 					   "%d %s, %d %s.",
 					   daze, ngettext("day","days",daze), min, ngettext("minute","minutes",min));
 			}
 		} else
-			g_snprintf(ret, 256, "%d %s.", daze, ngettext("day","days",daze));
+			ret = g_strdup_printf("%d %s.", daze, ngettext("day","days",daze));
 	} else {
 		if (hrs) {
 			if (min) {
-				g_snprintf(ret, 256,
+				ret = g_strdup_printf(
 					   "%d %s, %d %s.",
 					   hrs, ngettext("hour","hours",hrs), min, ngettext("minute","minutes",min));
 			} else {
-				g_snprintf(ret, 256, "%d %s.", hrs, ngettext("hour","hours",hrs));
+				ret = g_strdup_printf("%d %s.", hrs, ngettext("hour","hours",hrs));
 			}
 		} else {
-			g_snprintf(ret, 256, "%d %s.", min, ngettext("minute","minutes",min));
+			ret = g_strdup_printf("%d %s.", min, ngettext("minute","minutes",min));
 		}
 	}