if (ird.cal == NULL) return;
- // Here we go: put the VEVENT into the VCALENDAR. We now no longer
- // are responsible for "the_request"'s memory -- it will be freed
- // when we free "encaps".
+ // Here we go: put the VEVENT componment into the VCALENDAR container.
- // If the top-level component is *not* a VCALENDAR, we can drop it right in.
- // This will almost never happen.
+ // If the top-level component is *not* a VCALENDAR container, we can drop it right in.
+ // This is rare but we have to be able to handle it.
if (icalcomponent_isa(ird.cal) != ICAL_VCALENDAR_COMPONENT) {
icalcomponent_add_component(encaps, ird.cal);
+ // And now, the parent VCALENDAR container owns the child component's memory.
}
- // In the more likely event that we're looking at a VCALENDAR with the VEVENT
- // and other components encapsulated inside, we have to extract them.
+ // In the more likely event that we're looking at a VCALENDAR container with the VEVENT
+ // and other components encapsulated inside, we have to extract them first.
else {
for (c = icalcomponent_get_first_component(ird.cal, ICAL_ANY_COMPONENT);
(c != NULL);
c = icalcomponent_get_next_component(ird.cal, ICAL_ANY_COMPONENT)
) {
-
// For VTIMEZONE components, suppress duplicates of the same tzid
-
if (icalcomponent_isa(c) == ICAL_VTIMEZONE_COMPONENT) {
icalproperty *p = icalcomponent_get_first_property(c, ICAL_TZID_PROPERTY);
if (p) {
icalcomponent_add_component(encaps, icalcomponent_new_clone(c));
}
}
- icalcomponent_free(ird.cal);
+ icalcomponent_free(ird.cal); // we cloned this component so free the original.
}
}