diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-10 20:04:47 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | dc9427d16ad5cf9c3129295b49b601cbfbe5f078 (patch) | |
tree | 6310a8b13c7d5367d013f3755a462bc00008b8db | |
parent | 8dcc33d8ab4081310d2e18b2c3d6c95141999698 (diff) | |
download | subsurface-dc9427d16ad5cf9c3129295b49b601cbfbe5f078.tar.gz |
Cleanup: rename unregister_trip() to remove_trip()
For consistency with remove_dive(). Moreover, swap parameter order
in remove_dive() so that both functions use the same parameter order.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | core/dive.h | 2 | ||||
-rw-r--r-- | core/divelist.c | 13 | ||||
-rw-r--r-- | core/divelist.h | 2 | ||||
-rw-r--r-- | core/divesite.c | 2 | ||||
-rw-r--r-- | desktop-widgets/command_divelist.cpp | 4 |
5 files changed, 11 insertions, 12 deletions
diff --git a/core/dive.h b/core/dive.h index 25df599e4..169b02e57 100644 --- a/core/dive.h +++ b/core/dive.h @@ -407,7 +407,7 @@ struct dive *unregister_dive(int idx); extern void delete_single_dive(int idx); extern void insert_trip(dive_trip_t *trip, struct trip_table *trip_table_arg); -extern void unregister_trip(dive_trip_t *trip, struct trip_table *trip_table_arg); +extern void remove_trip(dive_trip_t *trip, struct trip_table *trip_table_arg); extern void free_trip(dive_trip_t *trip); extern timestamp_t trip_date(const struct dive_trip *trip); diff --git a/core/divelist.c b/core/divelist.c index 5fe41a7d9..9f99f0a8e 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 /* divelist.c */ -/* core logic for the dive list */ #include <unistd.h> #include <stdio.h> #include <stdlib.h> @@ -916,7 +915,7 @@ static MAKE_GET_IDX(trip_table, struct dive_trip *, trips) MAKE_SORT(dive_table, struct dive *, dives, comp_dives) MAKE_SORT(trip_table, struct dive_trip *, trips, comp_trips) -void remove_dive(struct dive_table *table, const struct dive *dive) +void remove_dive(const struct dive *dive, struct dive_table *table) { int idx = get_idx_in_dive_table(table, dive); if (idx >= 0) @@ -934,14 +933,14 @@ struct dive_trip *unregister_dive_from_trip(struct dive *dive) if (!trip) return NULL; - remove_dive(&trip->dives, dive); + remove_dive(dive, &trip->dives); dive->divetrip = NULL; return trip; } static void delete_trip(dive_trip_t *trip, struct trip_table *trip_table_arg) { - unregister_trip(trip, trip_table_arg); + remove_trip(trip, trip_table_arg); free_trip(trip); } @@ -1004,7 +1003,7 @@ dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive, struct trip_tab /* remove trip from the trip-list, but don't free its memory. * caller takes ownership of the trip. */ -void unregister_trip(dive_trip_t *trip, struct trip_table *trip_table_arg) +void remove_trip(dive_trip_t *trip, struct trip_table *trip_table_arg) { int idx = get_idx_in_trip_table(trip_table_arg, trip); assert(!trip->dives.nr); @@ -1476,7 +1475,7 @@ static bool merge_dive_tables(struct dive_table *dives_from, struct dive_table * struct dive *dive_to_add = dives_from->dives[i]; if (delete_from) - remove_dive(delete_from, dive_to_add); + remove_dive(dive_to_add, delete_from); /* Find insertion point. */ while (j < dives_to->nr && dive_less_than(dives_to->dives[j], dive_to_add)) @@ -1759,7 +1758,7 @@ void process_imported_dives(struct dive_table *import_table, struct trip_table * insert_dive(dives_to_add, d); sequence_changed |= !dive_is_after_last(d); - remove_dive(import_table, d); + remove_dive(d, import_table); } /* Then, add trip to list of trips to add */ diff --git a/core/divelist.h b/core/divelist.h index 831d5a3c1..befbc780a 100644 --- a/core/divelist.h +++ b/core/divelist.h @@ -38,7 +38,7 @@ extern void add_single_dive(int idx, struct dive *dive); extern void get_dive_gas(const struct dive *dive, int *o2_p, int *he_p, int *o2low_p); extern int get_divenr(const struct dive *dive); extern struct dive_trip *unregister_dive_from_trip(struct dive *dive); -extern void remove_dive(struct dive_table *table, const struct dive *dive); +extern void remove_dive(const struct dive *dive, struct dive_table *table); extern void remove_dive_from_trip(struct dive *dive, struct trip_table *trip_table_arg); extern dive_trip_t *alloc_trip(void); extern dive_trip_t *create_trip_from_dive(struct dive *dive); diff --git a/core/divesite.c b/core/divesite.c index 23ef62070..fe4e23808 100644 --- a/core/divesite.c +++ b/core/divesite.c @@ -391,7 +391,7 @@ struct dive_site *unregister_dive_from_dive_site(struct dive *d) struct dive_site *ds = d->dive_site; if (!ds) return NULL; - remove_dive(&ds->dives, d); + remove_dive(d, &ds->dives); d->dive_site = NULL; return ds; } diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp index c7dad70e4..59dec85c3 100644 --- a/desktop-widgets/command_divelist.cpp +++ b/desktop-widgets/command_divelist.cpp @@ -73,7 +73,7 @@ DiveToAdd DiveListBase::removeDive(struct dive *d, std::vector<OwningTripPtr> &t diveSiteCountChanged(d->dive_site); res.site = unregister_dive_from_dive_site(d); if (res.trip && res.trip->dives.nr == 0) { - unregister_trip(res.trip, &trip_table); // Remove trip from backend + remove_trip(res.trip, &trip_table); // Remove trip from backend tripsToAdd.emplace_back(res.trip); // Take ownership of trip } @@ -253,7 +253,7 @@ static OwningTripPtr moveDiveToTrip(DiveToTrip &diveToTrip) // Remove dive from trip - if this is the last dive in the trip, remove the whole trip. dive_trip *trip = unregister_dive_from_trip(diveToTrip.dive); if (trip && trip->dives.nr == 0) { - unregister_trip(trip, &trip_table); // Remove trip from backend + remove_trip(trip, &trip_table); // Remove trip from backend res.reset(trip); } |