aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2007-04-07 11:24:19 +0800
committerMatthew Barnes <mbarnes@src.gnome.org>2007-04-07 11:24:19 +0800
commitae2246b944b66b5fccf21e3008c2d63f38833b05 (patch)
treec1aa4229e3d5268f5301f1ff954e95f164d33aa4 /calendar
parent6f9d514d205215465b89deb4db28f6ecb403dff5 (diff)
downloadgsoc2013-evolution-ae2246b944b66b5fccf21e3008c2d63f38833b05.tar
gsoc2013-evolution-ae2246b944b66b5fccf21e3008c2d63f38833b05.tar.gz
gsoc2013-evolution-ae2246b944b66b5fccf21e3008c2d63f38833b05.tar.bz2
gsoc2013-evolution-ae2246b944b66b5fccf21e3008c2d63f38833b05.tar.lz
gsoc2013-evolution-ae2246b944b66b5fccf21e3008c2d63f38833b05.tar.xz
gsoc2013-evolution-ae2246b944b66b5fccf21e3008c2d63f38833b05.tar.zst
gsoc2013-evolution-ae2246b944b66b5fccf21e3008c2d63f38833b05.zip
Use a GString to construct the body contents and also fix several memory
2007-04-06 Matthew Barnes <mbarnes@redhat.com> * gui/itip-utils.c (reply_to_calendar_comp): Use a GString to construct the body contents and also fix several memory leaks. (#408423) Based on a patch from Daniel Gryniewicz. svn path=/trunk/; revision=33397
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog6
-rw-r--r--calendar/gui/itip-utils.c73
2 files changed, 40 insertions, 39 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 03ac9e5ecf..3b0e590eb1 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,11 @@
2007-04-06 Matthew Barnes <mbarnes@redhat.com>
+ * gui/itip-utils.c (reply_to_calendar_comp):
+ Use a GString to construct the body contents and also fix several
+ memory leaks. (#408423) Based on a patch from Daniel Gryniewicz.
+
+2007-04-06 Matthew Barnes <mbarnes@redhat.com>
+
* gui/memos-component.c (impl__get_userCreatableItems):
Fix a duplicate keyboard shortcut. (#353922)
Patch from Diego Escalante Urrelo
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index b8c5324369..10a598211e 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -1411,12 +1411,12 @@ reply_to_calendar_comp (ECalComponentItipMethod method, ECalComponent *send_comp
if (e_cal_component_get_vtype (comp) == E_CAL_COMPONENT_EVENT){
- char *body = NULL;
- char *orig_from = (char *) malloc (sizeof (char) * 100);
+ GString *body;
+ char *orig_from = NULL;
char *description = NULL;
- char *subject = (char *) malloc (sizeof (char) * 100);
- char *location = (char *) malloc (sizeof (char) * 100);
- char *time = (char *) malloc (sizeof (char) * 64);
+ char *subject = NULL;
+ const char *location = NULL;
+ char *time = NULL;
char *html_description = NULL;
GSList *text_list = NULL;
ECalComponentOrganizer organizer;
@@ -1448,11 +1448,9 @@ reply_to_calendar_comp (ECalComponentItipMethod method, ECalComponent *send_comp
e_cal_component_get_organizer (comp, &organizer);
if (organizer.value)
orig_from = g_strdup (itip_strip_mailto (organizer.value));
- else
- orig_from = "";
- e_cal_component_get_location (comp, (const char **)&location);
+ e_cal_component_get_location (comp, &location);
if (!location)
location = "Unspecified";
@@ -1469,46 +1467,43 @@ reply_to_calendar_comp (ECalComponentItipMethod method, ECalComponent *send_comp
start_zone = calendar_config_get_icaltimezone ();
start = icaltime_as_timet_with_zone (*dtstart.value, start_zone);
- strcpy (time, ctime (&start));
+ time = g_strdup (ctime (&start));
}
- body = "<br><br><hr><br><b>______ Original Appointment ______ </b><br><br><table>";
+ body = g_string_new ("<br><br><hr><br><b>______ Original Appointment ______ </b><br><br><table>");
- if (orig_from && *orig_from){
- char *part1 = (char *) malloc (sizeof (char) * 200);
- sprintf (part1, "<tr><td><b>From</b></td><td>:</td><td>%s</td></tr>", orig_from);
- body = g_strconcat (body, (gchar *)part1, NULL);
- g_free (part1);
- }
+ if (orig_from && *orig_from)
+ g_string_append_printf (body,
+ "<tr><td><b>From</b></td>"
+ "<td>:</td><td>%s</td></tr>", orig_from);
+ g_free (orig_from);
- if (subject){
- char *part2 = (char *) malloc (sizeof (char) * 100);
- sprintf (part2, "<tr><td><b>Subject</b></td><td>:</td><td>%s</td></tr>", subject);
- body = g_strconcat (body, (gchar *)part2, NULL);
- g_free (part2);
- }
-
- {
- char *part3 = (char *) malloc (sizeof (char) * 100);
- sprintf (part3, "<tr><td><b>Location</b></td><td>:</td><td>%s</td></tr>", location);
- body = g_strconcat (body, (gchar *)part3, NULL);
- g_free (part3);
- }
+ if (subject)
+ g_string_append_printf (body,
+ "<tr><td><b>Subject</b></td>"
+ "<td>:</td><td>%s</td></tr>", subject);
+ g_free (subject);
- if (time){
- char *part4 = (char *) malloc (sizeof (char) * 100);
- sprintf (part4, "<tr><td><b>Time</b></td><td>:</td><td>%s</td></tr></table><br>", time);
- body = g_strconcat (body, (gchar *)part4, NULL);
- g_free (part4);
- }
+ g_string_append_printf (body,
+ "<tr><td><b>Location</b></td>"
+ "<td>:</td><td>%s</td></tr>", location);
- html_description = html_new_lines_for (description);
- body = g_strconcat (body, (gchar *)html_description, NULL);
+ if (time)
+ g_string_append_printf (body,
+ "<tr><td><b>Time</b></td>"
+ "<td>:</td><td>%s</td></tr>", time);
+ g_free (time);
+
+ g_string_append_printf (body, "</table><br>");
+ html_description = html_new_lines_for (description);
+ g_string_append (body, html_description);
g_free (html_description);
-
- GNOME_Evolution_Composer_setBody (composer_server, body, "text/html", &ev);
+
+ GNOME_Evolution_Composer_setBody (composer_server, body->str, "text/html", &ev);
+ g_string_free (body, TRUE);
+
if (BONOBO_EX (&ev)) {
g_warning ("Unable to set body text while sending iTip message");
goto cleanup;