From 30ee022b04356986846b4eedc48262af1e6cada7 Mon Sep 17 00:00:00 2001 From: djcb Date: Sun, 15 Aug 2010 13:32:43 +0300 Subject: [PATCH] * mu-msg-str: use g_format_size_for_display when we have GLib >= 2.16 --- src/mu-msg-str.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/mu-msg-str.c b/src/mu-msg-str.c index f9e61597..83c9fc57 100644 --- a/src/mu-msg-str.c +++ b/src/mu-msg-str.c @@ -48,12 +48,23 @@ mu_msg_str_size_s (size_t s) /* note: we we use the powers-of-10, not powers-of-2 */ static char buf[32]; - + +#ifdef HAVE_GLIB216 + char *tmp; + + tmp = g_format_size_for_display ((goffset)s); + strncpy (buf, tmp, sizeof(buf)); + buf[sizeof(buf) -1] = '\0'; /* just in case */ + g_free (tmp); + +#else if (s >= 1000 * 1000) g_snprintf(buf, sizeof(buf), "%.1f MB", (double)s/(1000*1000)); else g_snprintf(buf, sizeof(buf), "%.1f kB", (double)s/(1000)); +#endif /*HAVE_GLIB216*/ + return buf; }