diff options
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/parse-xml.c b/parse-xml.c index 90ad91c79..44ef45746 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1171,13 +1171,20 @@ static void dive_start(void) return; cur_dive = alloc_dive(); memset(&cur_tm, 0, sizeof(cur_tm)); + if (cur_trip) { + cur_dive->divetrip = cur_trip; + cur_dive->tripflag = IN_TRIP; + } } static void dive_end(void) { - if (!is_dive()) + if (!cur_dive) return; - record_dive(cur_dive); + if (!is_dive()) + free(cur_dive); + else + record_dive(cur_dive); cur_dive = NULL; cur_cylinder_index = 0; cur_ws_index = 0; @@ -1187,6 +1194,7 @@ static void trip_start(void) { if (cur_trip) return; + dive_end(); cur_trip = calloc(sizeof(dive_trip_t),1); memset(&cur_tm, 0, sizeof(cur_tm)); } @@ -1262,14 +1270,14 @@ static void entry(const char *name, int size, const char *raw) try_to_fill_sample(cur_sample, name, buf); return; } - if (cur_trip) { - try_to_fill_trip(&cur_trip, name, buf); - return; - } if (cur_dive) { try_to_fill_dive(&cur_dive, name, buf); return; } + if (cur_trip) { + try_to_fill_trip(&cur_trip, name, buf); + return; + } free(buf); } |