From ca50d9fad97731aefa9bca4075ba6f655c6e742e Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Wed, 15 Apr 1998 06:37:34 +0000 Subject: Routine to destory rows array properly. 1998-04-15 Miguel de Icaza * gncal-full-day.c (layout_kill_rows): Routine to destory rows array properly. * gncal-year-view.c (gncal_year_view_new): Add missing year in call to strftime. * calobj.c (ical_object_create_from_vobject): Fixed memory leaks from the return values of versit's fakeCString. svn path=/trunk/; revision=136 --- calendar/pcs/calobj.c | 99 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 33 deletions(-) (limited to 'calendar/pcs/calobj.c') diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index 237017a6f9..f02feaf7a1 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -383,7 +383,7 @@ load_recurrence (iCalObject *o, char *str) } #define is_a_prop_of(obj,prop) isAPropertyOf (obj,prop) -#define str_val(obj) fakeCString (vObjectUStringZValue (obj)) +#define str_val(obj) the_str = fakeCString (vObjectUStringZValue (obj)) #define has(obj,prop) (vo = isAPropertyOf (obj, prop)) /* FIXME: we need to load the recurrence properties */ @@ -394,6 +394,7 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) iCalObject *ical; VObject *vo; VObjectIterator i; + char *the_str; ical = g_new0 (iCalObject, 1); @@ -405,97 +406,128 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) return 0; /* uid */ - if (has (o, VCUniqueStringProp)) + if (has (o, VCUniqueStringProp)){ ical->uid = g_strdup (str_val (vo)); - + free (the_str); + } + /* seq */ - if (has (o, VCSequenceProp)) + if (has (o, VCSequenceProp)){ ical->seq = atoi (str_val (vo)); - else + free (the_str); + } else ical->seq = 0; /* dtstart */ - if (has (o, VCDTstartProp)) + if (has (o, VCDTstartProp)){ ical->dtstart = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->dtstart = 0; /* dtend */ - if (has (o, VCDTendProp)) + if (has (o, VCDTendProp)){ ical->dtend = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->dtend = 0; /* dcreated */ - if (has (o, VCDCreatedProp)) + if (has (o, VCDCreatedProp)){ ical->created = time_from_isodate (str_val (vo)); + free (the_str); + } /* completed */ - if (has (o, VCCompletedProp)) + if (has (o, VCCompletedProp)){ ical->completed = time_from_isodate (str_val (vo)); + free (the_str); + } /* last_mod */ - if (has (o, VCLastModifiedProp)) + if (has (o, VCLastModifiedProp)){ ical->last_mod = time_from_isodate (str_val (vo)); - else + free (the_str); + } else ical->last_mod = now; /* exdate */ - if (has (o, VCExpDateProp)) + if (has (o, VCExpDateProp)){ ical->exdate = set_date_list (str_val (vo)); + free (the_str); + } /* description/comment */ - if (has (o, VCDescriptionProp)) + if (has (o, VCDescriptionProp)){ ical->comment = g_strdup (str_val (vo)); + free (the_str); + } /* summary */ - if (has (o, VCSummaryProp)) + if (has (o, VCSummaryProp)){ ical->summary = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->summary = g_strdup (""); /* status */ - if (has (o, VCStatusProp)) + if (has (o, VCStatusProp)){ ical->status = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->status = g_strdup ("NEEDS ACTION"); - if (has (o, VCClassProp)) + if (has (o, VCClassProp)){ ical->class = g_strdup (str_val (vo)); - else + free (the_str); + } else ical->class = "PUBLIC"; /* categories */ - if (has (o, VCCategoriesProp)) + if (has (o, VCCategoriesProp)){ ical->categories = set_list (str_val (vo), ","); - + free (the_str); + } + /* resources */ - if (has (o, VCResourcesProp)) + if (has (o, VCResourcesProp)){ ical->resources = set_list (str_val (vo), ";"); + free (the_str); + } /* priority */ - if (has (o, VCPriorityProp)) + if (has (o, VCPriorityProp)){ ical->priority = atoi (str_val (vo)); - + free (the_str); + } + /* tranparency */ - if (has (o, VCTranspProp)) + if (has (o, VCTranspProp)){ ical->transp = atoi (str_val (vo)) ? ICAL_TRANSPARENT : ICAL_OPAQUE; + free (the_str); + } /* related */ - if (has (o, VCRelatedToProp)) + if (has (o, VCRelatedToProp)){ ical->related = set_list (str_val (vo), ";"); - + free (the_str); + } + /* attach */ initPropIterator (&i, o); while (moreIteration (&i)){ vo = nextVObject (&i); - if (strcmp (vObjectName (vo), VCAttachProp) == 0) + if (strcmp (vObjectName (vo), VCAttachProp) == 0){ ical->attach = g_list_prepend (ical->attach, g_strdup (str_val (vo))); + free (the_str); + } } /* url */ - if (has (o, VCURLProp)) + if (has (o, VCURLProp)){ ical->url = g_strdup (str_val (vo)); + free (the_str); + } /* FIXME: dalarm */ if (has (o, VCDAlarmProp)) @@ -514,12 +546,13 @@ ical_object_create_from_vobject (VObject *o, const char *object_name) ; /* FIXME: rrule */ - if (has (o, VCRRuleProp)) + if (has (o, VCRRuleProp)){ if (!load_recurrence (ical, str_val (vo))) { ical_object_destroy (ical); return NULL; } - + free (the_str); + } return ical; } -- cgit v1.2.3