diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-09-05 13:54:22 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-09-05 13:54:22 -0700 |
commit | 4679f4fbbc1f303b963b4eabebbbc9c684299619 (patch) | |
tree | 70376feaa89fdf4470c5ffadd5ccc5580d3ad88e /dive.h | |
parent | 6d0af91398b9ccd1cc29f087a9b695d0ffdf92fe (diff) | |
download | subsurface-4679f4fbbc1f303b963b4eabebbbc9c684299619.tar.gz |
Avoid duplicate dive_trip entries
When inserting a trip into the dive_trip_list we already check for
duplicate trips, but we still kept the additional dive_trip around.
With this change we instead replace it with the existing one.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.h')
-rw-r--r-- | dive.h | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -305,14 +305,16 @@ static void dump_trip_list(void) /* insert the trip into the dive_trip_list - but ensure you don't have * two trips for the same date; but if you have, make sure you don't * keep the one with less information */ -static inline void insert_trip(struct dive *_trip) +static void inline insert_trip(struct dive **trip) { - GList *result = FIND_TRIP(_trip->when); + struct dive *dive_trip = *trip; + GList *result = FIND_TRIP(dive_trip->when); if (result) { if (! DIVE_TRIP(result)->location) - DIVE_TRIP(result)->location = _trip->location; + DIVE_TRIP(result)->location = dive_trip->location; + *trip = DIVE_TRIP(result); } else { - dive_trip_list = g_list_insert_sorted(dive_trip_list, (_trip), dive_date_cmp); + dive_trip_list = g_list_insert_sorted(dive_trip_list, dive_trip, dive_date_cmp); } #ifdef DEBUG_TRIP dump_trip_list(); |