[balsa] Allocate string only if needed
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa] Allocate string only if needed
- Date: Thu, 11 Mar 2010 20:35:20 +0000 (UTC)
commit 404d4d6ed228098f56ddb1b6ac866054176c7b04
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Thu Mar 11 15:32:58 2010 -0500
Allocate string only if needed
* libbalsa/files.c (libbalsa_icon_finder): allocate content_type
only if needed.
ChangeLog | 5 +++++
libbalsa/files.c | 16 +++++++---------
2 files changed, 12 insertions(+), 9 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8156e46..0492923 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-03-11 Peter Bloomfield
+
+ * libbalsa/files.c (libbalsa_icon_finder): allocate string only
+ if needed.
+
2010-03-07 Albrecht DreÃ?
* src/balsa-mime-widget-text.c: do not mangle quotation characters
diff --git a/libbalsa/files.c b/libbalsa/files.c
index 98fc36d..19d8f4f 100644
--- a/libbalsa/files.c
+++ b/libbalsa/files.c
@@ -131,7 +131,7 @@ GdkPixbuf *
libbalsa_icon_finder(const char *mime_type, const LibbalsaVfs * for_file,
gchar** used_type, GtkIconSize size)
{
- char *content_type;
+ const gchar *content_type;
gchar *icon = NULL;
GdkPixbuf *pixbuf = NULL;
gint width, height;
@@ -142,12 +142,12 @@ libbalsa_icon_finder(const char *mime_type, const LibbalsaVfs * for_file,
width = height = 16;
if (mime_type)
- content_type = g_strdup(mime_type);
+ content_type = mime_type;
else if (for_file) {
- content_type = g_strdup(libbalsa_vfs_get_mime_type(for_file));
+ content_type = libbalsa_vfs_get_mime_type(for_file);
filename = libbalsa_vfs_get_uri(for_file);
} else
- content_type = g_strdup("application/octet-stream");
+ content_type = "application/octet-stream";
/* ask GIO for the icon */
if ((icon_theme = gtk_icon_theme_get_default())) {
@@ -181,9 +181,7 @@ libbalsa_icon_finder(const char *mime_type, const LibbalsaVfs * for_file,
/* return if we found a proper pixbuf */
if (pixbuf) {
if (used_type)
- *used_type = content_type;
- else
- g_free(content_type);
+ *used_type = g_strdup(content_type);
return pixbuf;
}
}
@@ -204,8 +202,8 @@ libbalsa_icon_finder(const char *mime_type, const LibbalsaVfs * for_file,
g_free(icon);
}
- if(used_type) *used_type = content_type;
- else g_free(content_type);
+ if (used_type)
+ *used_type = g_strdup(content_type);
return pixbuf;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]